#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 errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int i;
  if (argc < 2) {
    fprintf(stderr, "Usage:\n\tperror <errno>...\n");
    return 1;
  }
  for (i = 1; i < argc; ++i) {
    fprintf(stderr, "%d: ", errno = atoi(argv[i]));
    perror("");
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    1173 <main+0x43>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e0 <main+0xb0>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d9 <main+0xa9>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%edx
mov    0x2e29(%rip),%rax
mov    %edx,(%rax)
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xe54(%rip),%rdi
call   1040 <perror@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117a <main+0x4a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    115e <main+0x2e>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%ebp
jmp    11b1 <main+0x81>
mov    %rsi,%r12
mov    %edi,%r13d
mov    $0x1,%r14d
lea    0xea9(%rip),%r15
xor    %ebp,%ebp
mov    0x2e66(%rip),%rax
mov    (%rax),%ebx
mov    (%r12,%r14,8),%rdi
call   1050 <atoi@plt>
mov    0x2e4c(%rip),%rcx
mov    %eax,(%rcx)
mov    %ebx,%edi
lea    0xe84(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r15,%rdi
call   1040 <perror@plt>
add    $0x1,%r14
cmp    %r14,%r13
jne    1173 <main+0x43>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Usage:\0A\09perror <errno>...\0A\00"
@.str.1 = [5 x i8] c"%d: \00"
@errno = global i32 0
@.str.2 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %31
12: ; preds = %2
store i32 1, i32* %6
br label %13
13: ; preds = %27, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* @errno
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %17
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %13
30: ; preds = %13
store i32 0, i32* %3
br label %31
31: ; preds = %30, %9
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Usage:\0A\09perror <errno>...\0A\00"
@.str.1 = [5 x i8] c"%d: \00"
@errno = global i32 0
@.str.2 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %19
9: ; preds = %4, %9
%10 = phi i64 [ 1, %4 ], [ %17, %9 ]
%11 = load i32, i32* @stderr
%12 = getelementptr inbounds i8*, i8** %1, i64 %10
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
store i32 %14, i32* @errno
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %5
br i1 %18, label %19, label %9
19: ; preds = %9, %6
%20 = phi i32 [ 1, %6 ], [ 0, %9 ]
ret i32 %20
}