#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*/ error_strerror(int, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int ret;
  if (argc != 2) {
    printf("\n usage: strerror <errorcode>\n");
    return (0);
  }
  ret = atoi(argv[1]);
  if (ret > 0)
    ret = -ret;
  if (ret != 0) {
    char error_buf[200];
    error_strerror(ret, error_buf, 200);
    printf("Last error was: %d - %s\n\n", ret, error_buf);
  }
  return (ret);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116d <main+0x3d>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cb <main+0x9b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    118f <main+0x5f>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11c5 <main+0x95>
mov    -0x14(%rbp),%edi
lea    -0xe0(%rbp),%rsi
mov    $0xc8,%edx
call   1050 <error_strerror@plt>
mov    -0x14(%rbp),%esi
lea    -0xe0(%rbp),%rdx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
cmp    $0x2,%edi
jne    1188 <main+0x48>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
neg    %ebx
cmovns %eax,%ebx
jae    1194 <main+0x54>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc8,%edx
call   1060 <error_strerror@plt>
lea    0xe86(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1196 <main+0x56>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0A usage: strerror <errorcode>\0A\00"
@.str.1 = [26 x i8] c"Last error was: %d - %s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %34
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i32, i32* %6
%21 = sub nsw i32 0, %20
store i32 %21, i32* %6
br label %22
22: ; preds = %19, %12
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* %6
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%28 = call i32 @error_strerror(i32 %26, i8* %27, i32 200)
%29 = load i32, i32* %6
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %29, i8* %30)
br label %32
32: ; preds = %25, %22
%33 = load i32, i32* %6
store i32 %33, i32* %3
br label %34
34: ; preds = %32, %10
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"Last error was: %d - %s\0A\0A\00"
@str = [30 x i8] c"\0A usage: strerror <errorcode>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 @llvm.abs.i32(i32 %10, i1 false)
%12 = sub i32 0, %11
%13 = icmp eq i32 %10, 0
br i1 %13, label %18, label %14
14: ; preds = %7
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%16 = call i32 @error_strerror(i32 %12, i8* %15, i32 200)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %15)
br label %18
18: ; preds = %7, %14, %5
%19 = phi i32 [ 0, %5 ], [ %12, %14 ], [ 0, %7 ]
ret i32 %19
}