#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 */
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int);
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "This program expects one argument.\n");
    return 1;
  }
  char *endptr = NULL;
  errno = 0;
  long arg = strtol(argv[1], &endptr, 10);
  if (*argv[1] == '\0' || *endptr != '\0') {
    fprintf(stderr, "Argument is not a valid decimal number: '%s'\n", argv[1]);
    return 1;
  }
  if (errno) {
    fprintf(stderr, "Argument parse error: '%s': %m\n", argv[1]);
    return 1;
  }
  for (long i = 1; i <= arg; ++i) {
    printf("%ld\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)
cmpl   $0x2,-0x8(%rbp)
je     1173 <main+0x43>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    126c <main+0x13c>
movq   $0x0,-0x18(%rbp)
mov    0x2e56(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c7 <main+0x97>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f2 <main+0xc2>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    126c <main+0x13c>
mov    0x2ddf(%rip),%rax
cmpq   $0x0,(%rax)
je     122e <main+0xfe>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    126c <main+0x13c>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jg     1265 <main+0x135>
mov    -0x28(%rbp),%rsi
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1236 <main+0x106>
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   %rbx
push   %rax
cmp    $0x2,%edi
jne    11a3 <main+0x73>
mov    %rsi,%rbx
movq   $0x0,(%rsp)
mov    0x2e8a(%rip),%rbp
movq   $0x0,0x0(%rbp)
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x8(%rbx),%rdx
lea    0xeb2(%rip),%rsi
cmpb   $0x0,(%rdx)
je     1191 <main+0x61>
mov    %rax,%r14
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    1191 <main+0x61>
cmpq   $0x0,0x0(%rbp)
je     11cc <main+0x9c>
lea    0xec1(%rip),%rsi
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11ba <main+0x8a>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
test   %r14,%r14
jle    11bf <main+0x8f>
neg    %r14
mov    $0x1,%ebx
lea    0xe90(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
jne    11f0 <main+0xc0>
jmp    11bf <main+0x8f>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"This program expects one argument.\0A\00"
@errno = global i64 0
@.str.1 = [46 x i8] c"Argument is not a valid decimal number: '%s'\0A\00"
@.str.2 = [32 x i8] c"Argument parse error: '%s': %m\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %57
14: ; preds = %2
store i8* null, i8** %6
store i64 0, i64* @errno
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strtol(i8* %17, i8** %6, i32 10)
store i64 %18, i64* %7
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %14
%26 = load i8*, i8** %6
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %25, %14
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %34)
store i32 1, i32* %3
br label %57
36: ; preds = %25
%37 = load i64, i64* @errno
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %43)
store i32 1, i32* %3
br label %57
45: ; preds = %36
store i64 1, i64* %8
br label %46
46: ; preds = %53, %45
%47 = load i64, i64* %8
%48 = load i64, i64* %7
%49 = icmp sle i64 %47, %48
br i1 %49, label %50, label %56
50: ; preds = %46
%51 = load i64, i64* %8
%52 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %51)
br label %53
53: ; preds = %50
%54 = load i64, i64* %8
%55 = add nsw i64 %54, 1
store i64 %55, i64* %8
br label %46
56: ; preds = %46
store i32 0, i32* %3
br label %57
57: ; preds = %56, %39, %30, %11
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"This program expects one argument.\0A\00"
@errno = global i64 0
@.str.1 = [46 x i8] c"Argument is not a valid decimal number: '%s'\0A\00"
@.str.2 = [32 x i8] c"Argument parse error: '%s': %m\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %36
8: ; preds = %2
%9 = bitcast i8** %3 to i8*
store i8* null, i8** %3
store i64 0, i64* @errno
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strtol(i8* %11, i8** %3, i32 10)
%13 = load i8*, i8** %10
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %30, label %16
16: ; preds = %8
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i64, i64* @errno
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = icmp slt i64 %12, 1
br i1 %24, label %34, label %25
25: ; preds = %23, %25
%26 = phi i64 [ %28, %25 ], [ 1, %23 ]
%27 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %26)
%28 = add nuw i64 %26, 1
%29 = icmp eq i64 %26, %12
br i1 %29, label %34, label %25
30: ; preds = %20, %8, %16
%31 = phi i8* [ getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), %16 ], [ getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %20 ]
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* %31, i8* %13)
br label %34
34: ; preds = %25, %30, %23
%35 = phi i32 [ 0, %23 ], [ 1, %30 ], [ 0, %25 ]
br label %36
36: ; preds = %34, %5
%37 = phi i32 [ 1, %5 ], [ %35, %34 ]
ret i32 %37
}