#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ generateLine();
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
unsigned long strtoul(char *, char **, int);
int main(int argc, char **argv) {
  unsigned long number;
  char *invalid = NULL;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <number-of-records>", argv[0]);
    return 1;
  }
  number = strtoul(argv[1], &invalid, 10);
  if (strlen(invalid) != 0) {
    fprintf(stderr, "Invalid number: %s", argv[1]);
    return 1;
  }
  for (int i = 0; i < number; i++) {
    generateLine();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1190 <main+0x50>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1217 <main+0xd7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     11e6 <main+0xa6>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1217 <main+0xd7>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1210 <main+0xd0>
mov    $0x0,%al
call   1040 <generateLine@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ed <main+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jge    1152 <main+0x22>
lea    0xeb0(%rip),%rsi
jmp    117d <main+0x4d>
mov    0x8(%r14),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     119e <main+0x6e>
add    $0x8,%r14
lea    0xea1(%rip),%rsi
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
call   1040 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
test   %rbx,%rbx
je     1193 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <generateLine@plt>
add    $0xffffffffffffffff,%rbx
jne    11b0 <main+0x80>
jmp    1193 <main+0x63>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <number-of-records>\00"
@.str.1 = [19 x i8] c"Invalid number: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %43
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strtoul(i8* %20, i8** %7, i32 10)
store i64 %21, i64* %6
%22 = load i8*, i8** %7
%23 = call i64 @strlen(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %17
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %29)
store i32 1, i32* %3
br label %43
31: ; preds = %17
store i32 0, i32* %8
br label %32
32: ; preds = %39, %31
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = load i64, i64* %6
%36 = icmp ult i64 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = call i32 (...) @generateLine()
br label %39
39: ; preds = %37
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %32
42: ; preds = %32
store i32 0, i32* %3
br label %43
43: ; preds = %42, %25, %11
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <number-of-records>\00"
@.str.1 = [19 x i8] c"Invalid number: %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %20, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i64 @strtoul(i8* %8, i8** %3, i32 10)
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %6
%14 = icmp eq i64 %9, 0
br i1 %14, label %26, label %15
15: ; preds = %13, %15
%16 = phi i64 [ %18, %15 ], [ 0, %13 ]
%17 = tail call i32 (...) @generateLine()
%18 = add nuw i64 %16, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %26, label %15
20: ; preds = %6, %2
%21 = phi i8** [ %1, %2 ], [ %7, %6 ]
%22 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %6 ]
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %21
%25 = tail call i32 @fprintf(i32 %23, i8* %22, i8* %24)
br label %26
26: ; preds = %15, %20, %13
%27 = phi i32 [ 0, %13 ], [ 1, %20 ], [ 0, %15 ]
ret i32 %27
}