#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 EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freopen(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strncmp(char const *, char *, int);
int strtol(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  int is_binary = 0;
  int range, n;
  int i, j;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s [-b] <range> <number of ints>\n", argv[0]);
    fprintf(stderr, "with -b option output will be binary\n");
    return EXIT_FAILURE;
  }
  if (argc > 3) {
    if (!strncmp(argv[1], "-b", 3)) {
      is_binary = 1;
      argv++;
      argc--;
    }
  }
  errno = 0;
  range = strtol(argv[1], NULL, 0);
  if (errno) {
    perror("strtol");
    return EXIT_FAILURE;
  }
  errno = 0;
  n = strtol(argv[2], NULL, 0);
  if (errno) {
    perror("strtol");
    return EXIT_FAILURE;
  }
  if (is_binary)
    freopen(NULL, "wb", stdout);
  for (i = 0; i < range; i++) {
    for (j = 0; j < n / range; j++)
      printf("%d\n", i);
  }
  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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cd <main+0x6d>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    134c <main+0x1ec>
cmpl   $0x3,-0x8(%rbp)
jle    121a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe69(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1215 <main+0xb5>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    121a <main+0xba>
mov    0x2db7(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d93(%rip),%rax
cmpq   $0x0,(%rax)
je     126c <main+0x10c>
lea    0xdfc(%rip),%rdi
call   1080 <perror@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    134c <main+0x1ec>
mov    0x2d65(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d41(%rip),%rax
cmpq   $0x0,(%rax)
je     12be <main+0x15e>
lea    0xdaa(%rip),%rdi
call   1080 <perror@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    134c <main+0x1ec>
cmpl   $0x0,-0x14(%rbp)
je     12e1 <main+0x181>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    0xd7d(%rip),%rsi
call   1050 <freopen@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1345 <main+0x1e5>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    1332 <main+0x1d2>
mov    -0x20(%rbp),%esi
lea    0xd3d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12fb <main+0x19b>
jmp    1337 <main+0x1d7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12e8 <main+0x188>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
cmp    $0x1,%edi
jg     11a8 <main+0x48>
mov    0x2e69(%rip),%rbx
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xe7d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe96(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
jmp    1273 <main+0x113>
mov    $0x1,%bl
cmp    $0x4,%edi
jb     11d1 <main+0x71>
lea    0x8(%r14),%rbp
mov    0x8(%r14),%rdi
lea    0xe91(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
setne  %bl
cmove  %rbp,%r14
mov    0x2e00(%rip),%rbp
movq   $0x0,0x0(%rbp)
mov    0x8(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
cmpq   $0x0,0x0(%rbp)
jne    127c <main+0x11c>
mov    %eax,%r15d
movq   $0x0,0x0(%rbp)
mov    0x10(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
cmpq   $0x0,0x0(%rbp)
jne    127c <main+0x11c>
mov    %eax,%r14d
test   %bl,%bl
jne    1235 <main+0xd5>
mov    0x2da3(%rip),%rax
mov    (%rax),%edx
lea    0xe2b(%rip),%rsi
xor    %edi,%edi
call   1050 <freopen@plt>
test   %r15d,%r15d
jle    1271 <main+0x111>
mov    %r14d,%eax
cltd
idiv   %r15d
mov    %eax,%r14d
xor    %ebx,%ebx
lea    0xe0f(%rip),%r12
jmp    1258 <main+0xf8>
nop
add    $0x1,%ebx
cmp    %r15d,%ebx
je     1271 <main+0x111>
test   %r14d,%r14d
jle    1250 <main+0xf0>
mov    %r14d,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1260 <main+0x100>
jmp    1250 <main+0xf0>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdcf(%rip),%rdi
call   1080 <perror@plt>
jmp    119a <main+0x3a>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"Usage: %s [-b] <range> <number of ints>\0A\00"
@.str.1 = [38 x i8] c"with -b option output will be binary\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"-b\00"
@errno = global i64 0
@.str.3 = [7 x i8] c"strtol\00"
@.str.4 = [3 x i8] c"wb\00"
@stdout = global i32 0
@.str.5 = [4 x i8] c"%d\0A\00"
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
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %86
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 3
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strncmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 3)
%30 = icmp ne i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %25
store i32 1, i32* %6
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i32 1
store i8** %33, i8*** %5
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
br label %36
36: ; preds = %31, %25
br label %37
37: ; preds = %36, %22
store i64 0, i64* @errno
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strtol(i8* %40, i32* null, i32 0)
store i32 %41, i32* %7
%42 = load i64, i64* @errno
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
store i32 %46, i32* %3
br label %86
47: ; preds = %37
store i64 0, i64* @errno
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @strtol(i8* %50, i32* null, i32 0)
store i32 %51, i32* %8
%52 = load i64, i64* @errno
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %47
%55 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
store i32 %56, i32* %3
br label %86
57: ; preds = %47
%58 = load i32, i32* %6
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i32, i32* @stdout
%62 = call i32 @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %60, %57
store i32 0, i32* %9
br label %64
64: ; preds = %82, %63
%65 = load i32, i32* %9
%66 = load i32, i32* %7
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %85
68: ; preds = %64
store i32 0, i32* %10
br label %69
69: ; preds = %78, %68
%70 = load i32, i32* %10
%71 = load i32, i32* %8
%72 = load i32, i32* %7
%73 = sdiv i32 %71, %72
%74 = icmp slt i32 %70, %73
br i1 %74, label %75, label %81
75: ; preds = %69
%76 = load i32, i32* %9
%77 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %75
%79 = load i32, i32* %10
%80 = add nsw i32 %79, 1
store i32 %80, i32* %10
br label %69
81: ; preds = %69
br label %82
82: ; preds = %81
%83 = load i32, i32* %9
%84 = add nsw i32 %83, 1
store i32 %84, i32* %9
br label %64
85: ; preds = %64
store i32 0, i32* %3
br label %86
86: ; preds = %85, %54, %44, %13
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Usage: %s [-b] <range> <number of ints>\0A\00"
@.str.1 = [38 x i8] c"with -b option output will be binary\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"-b\00"
@errno = global i64 0
@.str.3 = [7 x i8] c"strtol\00"
@.str.4 = [3 x i8] c"wb\00"
@stdout = global i32 0
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
br label %59
11: ; preds = %2
%12 = icmp ugt i32 %0, 3
br i1 %12, label %13, label %20
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @strncmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 3)
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8** %14, i8** %1
%19 = xor i1 %17, true
br label %20
20: ; preds = %13, %11
%21 = phi i8** [ %1, %11 ], [ %18, %13 ]
%22 = phi i1 [ true, %11 ], [ %19, %13 ]
store i64 0, i64* @errno
%23 = getelementptr inbounds i8*, i8** %21, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @strtol(i8* nocapture %24, i32* null, i32 0)
%26 = load i64, i64* @errno
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %20
%29 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
br label %59
31: ; preds = %20
store i64 0, i64* @errno
%32 = getelementptr inbounds i8*, i8** %21, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32 @strtol(i8* nocapture %33, i32* null, i32 0)
%35 = load i64, i64* @errno
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %31
%38 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
br label %59
40: ; preds = %31
br i1 %22, label %44, label %41
41: ; preds = %40
%42 = load i32, i32* @stdout
%43 = tail call i32 @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %40
%45 = icmp sgt i32 %25, 0
br i1 %45, label %46, label %59
46: ; preds = %44
%47 = sdiv i32 %34, %25
%48 = icmp sgt i32 %47, 0
br label %49
49: ; preds = %46, %56
%50 = phi i32 [ 0, %46 ], [ %57, %56 ]
br i1 %48, label %51, label %56
51: ; preds = %49, %51
%52 = phi i32 [ %54, %51 ], [ 0, %49 ]
%53 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%54 = add nuw nsw i32 %52, 1
%55 = icmp eq i32 %54, %47
br i1 %55, label %56, label %51
56: ; preds = %51, %49
%57 = add nuw nsw i32 %50, 1
%58 = icmp eq i32 %57, %25
br i1 %58, label %59, label %49
59: ; preds = %56, %44, %37, %28, %4
%60 = phi i32 [ %10, %4 ], [ %30, %28 ], [ %39, %37 ], [ 0, %44 ], [ 0, %56 ]
ret i32 %60
}