#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*/ exit(int /*<<< orphan*/);
int fb2png(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char *argv[]) {
  char fn[128];
  if (argc == 2) {
    if (argv[1][0] == '-') {
      printf("Usage: fb2png [path/to/output.png]\n"
             "    The default output path is ./fbdump.png\n");
      exit(0);
    } else {
      sprintf(fn, "%s", argv[1]);
    }
  } else {
    sprintf(fn, "%s", "fbdump.png");
  }
  return fb2png(fn);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11aa <main+0x6a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    118a <main+0x4a>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xeb0(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11c4 <main+0x84>
lea    -0x90(%rbp),%rdi
lea    0xe98(%rip),%rsi
lea    0xe94(%rip),%rdx
call   1040 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1060 <fb2png@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x88,%rsp
cmp    $0x2,%edi
jne    115f <main+0x1f>
mov    0x8(%rsi),%rsi
cmpb   $0x2d,(%rsi)
je     1185 <main+0x45>
mov    %rsp,%rdi
call   1030 <strcpy@plt>
jmp    1175 <main+0x35>
movabs $0x702e706d75646266,%rax
70 2e 70
mov    %rax,(%rsp)
movl   $0x676e70,0x7(%rsp)
mov    %rsp,%rdi
call   1060 <fb2png@plt>
add    $0x88,%rsp
ret
lea    0xe74(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [80 x i8] c"Usage: fb2png [path/to/output.png]\0A The default output path is ./fbdump.png\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [11 x i8] c"fbdump.png\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
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, 2
br i1 %8, label %9, label %27
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 45
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %9
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %20
br label %30
27: ; preds = %2
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%29 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %27, %26
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%32 = call i32 @fb2png(i8* %31)
ret i32 %32
}

LLVM IR (-O2):
@.str.2 = [11 x i8] c"fbdump.png\00"
@str = [79 x i8] c"Usage: fb2png [path/to/output.png]\0A The default output path is ./fbdump.png\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %6
%15 = call i8* @strcpy(i8* %4, i8* %8)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %14
%18 = call i32 @fb2png(i8* %4)
ret i32 %18
}