#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*/ Usage(char *);
int /*<<< orphan*/ create_backing_file(char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *prog = argv[0];
  char *actual_backing_file = NULL;
  int in_place = 0;
  argv++;
  argc--;
  if (argc == 0)
    Usage(prog);
  if (!strcmp(argv[0], "-d")) {
    in_place = 1;
    argv++;
    argc--;
  }
  if (!strcmp(argv[0], "-b")) {
    actual_backing_file = argv[1];
    argv += 2;
    argc -= 2;
  }
  if (in_place) {
    if (argc != 1)
      Usage(prog);
    create_backing_file(argv[0], NULL, actual_backing_file);
  } else {
    if (argc != 2)
      Usage(prog);
    create_backing_file(argv[0], argv[1], actual_backing_file);
  }
  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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1188 <main+0x58>
mov    -0x18(%rbp),%rdi
call   1030 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c0 <main+0x90>
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe35(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11fd <main+0xcd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1233 <main+0x103>
cmpl   $0x1,-0x8(%rbp)
je     121a <main+0xea>
mov    -0x18(%rbp),%rdi
call   1030 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <create_backing_file@plt>
jmp    125e <main+0x12e>
cmpl   $0x2,-0x8(%rbp)
je     1246 <main+0x116>
mov    -0x18(%rbp),%rdi
call   1030 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <create_backing_file@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%r14
lea    0x8(%rsi),%r12
mov    %edi,%r13d
add    $0xffffffff,%r13d
jne    1158 <main+0x28>
mov    %r14,%rdi
call   1030 <Usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe9d(%rip),%rsi
call   1040 <strcmp@plt>
mov    %eax,%r15d
lea    0x10(%rbx),%rax
add    $0xfffffffe,%ebp
xor    %ecx,%ecx
test   %r15d,%r15d
cmove  %rax,%r12
sete   %cl
cmove  %ebp,%r13d
mov    0x8(%rbx,%rcx,8),%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b3 <main+0x83>
xor    %ebx,%ebx
test   %r15d,%r15d
je     11c5 <main+0x95>
cmp    $0x2,%r13d
je     11ac <main+0x7c>
mov    %r14,%rdi
call   1030 <Usage@plt>
mov    0x8(%r12),%rsi
jmp    11d5 <main+0xa5>
mov    0x8(%r12),%rbx
add    $0x10,%r12
add    $0xfffffffe,%r13d
test   %r15d,%r15d
jne    119e <main+0x6e>
cmp    $0x1,%r13d
je     11d3 <main+0xa3>
mov    %r14,%rdi
call   1030 <Usage@plt>
xor    %esi,%esi
mov    (%r12),%rdi
mov    %rbx,%rdx
call   1050 <create_backing_file@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [3 x i8] c"-b\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
store i8* %11, i8** %6
store i8* null, i8** %7
store i32 0, i32* %8
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %5
%14 = load i32, i32* %4
%15 = add nsw i32 %14, -1
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i8*, i8** %6
%20 = call i32 @Usage(i8* %19)
br label %21
21: ; preds = %18, %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %21
store i32 1, i32* %8
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i32 1
store i8** %29, i8*** %5
%30 = load i32, i32* %4
%31 = add nsw i32 %30, -1
store i32 %31, i32* %4
br label %32
32: ; preds = %27, %21
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %46, label %38
38: ; preds = %32
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
store i8* %41, i8** %7
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
store i8** %43, i8*** %5
%44 = load i32, i32* %4
%45 = sub nsw i32 %44, 2
store i32 %45, i32* %4
br label %46
46: ; preds = %38, %32
%47 = load i32, i32* %8
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %61
49: ; preds = %46
%50 = load i32, i32* %4
%51 = icmp ne i32 %50, 1
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i8*, i8** %6
%54 = call i32 @Usage(i8* %53)
br label %55
55: ; preds = %52, %49
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = load i8*, i8** %7
%60 = call i32 @create_backing_file(i8* %58, i8* null, i8* %59)
br label %76
61: ; preds = %46
%62 = load i32, i32* %4
%63 = icmp ne i32 %62, 2
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i8*, i8** %6
%66 = call i32 @Usage(i8* %65)
br label %67
67: ; preds = %64, %61
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 0
%70 = load i8*, i8** %69
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 1
%73 = load i8*, i8** %72
%74 = load i8*, i8** %7
%75 = call i32 @create_backing_file(i8* %70, i8* %73, i8* %74)
br label %76
76: ; preds = %67, %55
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-d\00"
@.str.1 = [3 x i8] c"-b\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = add nsw i32 %0, -1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @Usage(i8* %3)
br label %9
9: ; preds = %7, %2
%10 = load i8*, i8** %4
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = add nsw i32 %0, -2
%15 = select i1 %12, i8** %13, i8** %4
%16 = select i1 %12, i32 %14, i32 %5
%17 = load i8*, i8** %15
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %9
%21 = getelementptr inbounds i8*, i8** %15, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %15, i64 2
%24 = add nsw i32 %16, -2
br label %25
25: ; preds = %20, %9
%26 = phi i8** [ %15, %9 ], [ %23, %20 ]
%27 = phi i32 [ %16, %9 ], [ %24, %20 ]
%28 = phi i8* [ null, %9 ], [ %22, %20 ]
br i1 %12, label %29, label %33
29: ; preds = %25
%30 = icmp eq i32 %27, 1
br i1 %30, label %40, label %31
31: ; preds = %29
%32 = tail call i32 @Usage(i8* %3)
br label %40
33: ; preds = %25
%34 = icmp eq i32 %27, 2
br i1 %34, label %37, label %35
35: ; preds = %33
%36 = tail call i32 @Usage(i8* %3)
br label %37
37: ; preds = %35, %33
%38 = getelementptr inbounds i8*, i8** %26, i64 1
%39 = load i8*, i8** %38
br label %40
40: ; preds = %29, %31, %37
%41 = phi i8* [ %39, %37 ], [ null, %31 ], [ null, %29 ]
%42 = load i8*, i8** %26
%43 = tail call i32 @create_backing_file(i8* %42, i8* %41, i8* %28)
ret i32 0
}