#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
void main(int argc, char *argv[]) {
  int i;
  int bytes;
  if (argc < 2) {
    printf("usage: %s number of bytes \n", argv[0]);
    return;
  }
  bytes = strtol(argv[1], NULL, 0);
  FILE *output_ptr;
  output_ptr = fopen("video_ES.ES", "w");
  for (i = 0; i < bytes; i++) {
    putc(i, output_ptr);
  }
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1171 <main+0x31>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    11d0 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
lea    0xe8e(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11cb <main+0x8b>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <putc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a5 <main+0x65>
jmp    11d0 <main+0x90>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     115c <main+0x1c>
mov    (%rsi),%rsi
lea    0xead(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
mov    0x8(%rsi),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%r14d
lea    0xea7(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
test   %r14d,%r14d
jle    11a2 <main+0x62>
mov    %rax,%rbp
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %rbp,%rsi
call   1040 <putc@plt>
add    $0x1,%ebx
cmp    %ebx,%r14d
jne    1190 <main+0x50>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"usage: %s number of bytes \0A\00"
@.str.1 = [12 x i8] c"video_ES.ES\00"
@.str.2 = [2 x i8] c"w\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %33
15: ; preds = %2
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strtol(i8* %18, i32* null, i32 0)
store i32 %19, i32* %6
%20 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %7
store i32 0, i32* %5
br label %21
21: ; preds = %29, %15
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i32, i32* %5
%27 = load i32*, i32** %7
%28 = call i32 @putc(i32 %26, i32* %27)
br label %29
29: ; preds = %25
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %21
32: ; preds = %21
br label %33
33: ; preds = %32, %10
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"usage: %s number of bytes \0A\00"
@.str.1 = [12 x i8] c"video_ES.ES\00"
@.str.2 = [2 x i8] c"w\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strtol(i8* nocapture %9, i32* null, i32 0)
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %18
13: ; preds = %7, %13
%14 = phi i32 [ %16, %13 ], [ 0, %7 ]
%15 = tail call i32 @putc(i32 %14, i32* %11)
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %10
br i1 %17, label %18, label %13
18: ; preds = %13, %7, %4
ret void
}