#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 *, ...);
int get_line_size();
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int trim(int);
int main(int argc, char *argv[]) {
  int width;
  if (argc == 1) {
    width = get_line_size();
  } else if (argc == 2) {
    if (!sscanf(argv[1], "%i", &width)) {
      fprintf(stderr, "Cannot understand '%s'\n", argv[1]);
      return 1;
    }
  } else {
    fprintf(stderr, "Too many arguments\n");
    return 1;
  }
  return trim(width);
}


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   $0x1,-0x8(%rbp)
jne    116f <main+0x2f>
mov    $0x0,%al
call   1050 <get_line_size@plt>
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0xb2>
cmpl   $0x2,-0x8(%rbp)
jne    11ca <main+0x8a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe78(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x0,%eax
jne    11c5 <main+0x85>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xbd>
jmp    11ed <main+0xad>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xbd>
jmp    11f2 <main+0xb2>
mov    -0x14(%rbp),%edi
call   1030 <trim@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
je     1163 <main+0x23>
cmp    $0x1,%edi
jne    118a <main+0x4a>
xor    %eax,%eax
call   1050 <get_line_size@plt>
mov    %eax,%edi
mov    %eax,0xc(%rsp)
call   1030 <trim@plt>
jmp    11c3 <main+0x83>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe8f(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
test   %eax,%eax
je     11a3 <main+0x63>
mov    0xc(%rsp),%edi
call   1030 <trim@plt>
jmp    11c3 <main+0x83>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11be <main+0x7e>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Cannot understand '%s'\0A\00"
@.str.2 = [20 x i8] c"Too many arguments\0A\00"
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 eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @get_line_size()
store i32 %10, i32* %6
br label %31
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%19 = icmp ne i32 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %34
26: ; preds = %14
br label %30
27: ; preds = %11
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %34
30: ; preds = %26
br label %31
31: ; preds = %30, %9
%32 = load i32, i32* %6
%33 = call i32 @trim(i32 %32)
store i32 %33, i32* %3
br label %34
34: ; preds = %31, %27, %20
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Cannot understand '%s'\0A\00"
@.str.2 = [20 x i8] c"Too many arguments\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
switch i32 %0, label %18 [
i32 1, label %5
i32 2, label %7
]
5: ; preds = %2
%6 = tail call i32 (...) @get_line_size()
store i32 %6, i32* %3
br label %21
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = load i32, i32* %3
br label %21
14: ; preds = %7
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %8
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %24
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %24
21: ; preds = %12, %5
%22 = phi i32 [ %13, %12 ], [ %6, %5 ]
%23 = call i32 @trim(i32 %22)
br label %24
24: ; preds = %21, %18, %14
%25 = phi i32 [ %23, %21 ], [ 1, %14 ], [ 1, %18 ]
ret i32 %25
}