#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ write(int, int *, int);
int main(int argc, char *argv[]) {
  int f = -1;
  int i, top;
  if (argc == 2)
    top = atoi(argv[1]);
  else
    top = 1000000;
  for (i = 0; i < top; i++)
    write(1, &f, 4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    115c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1163 <main+0x43>
movl   $0xf4240,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1197 <main+0x77>
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116a <main+0x4a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
mov    $0xf4240,%ebx
cmp    $0x2,%edi
jne    1145 <main+0x25>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1167 <main+0x47>
lea    0x4(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0xffffffff,%ebx
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %8
br label %17
16: ; preds = %2
store i32 1000000, i32* %8
br label %17
17: ; preds = %16, %11
store i32 0, i32* %7
br label %18
18: ; preds = %24, %17
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = call i32 @write(i32 1, i32* %6, i32 4)
br label %24
24: ; preds = %22
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %18
27: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %2, %6
%12 = phi i32 [ %9, %6 ], [ 1000000, %2 ]
br label %13
13: ; preds = %11, %13
%14 = phi i32 [ %16, %13 ], [ 0, %11 ]
%15 = call i32 @write(i32 1, i32* %3, i32 4)
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %12
br i1 %17, label %18, label %13
18: ; preds = %13, %6
ret i32 0
}