#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);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ generateMakefile(char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ stderr;
char *strdup(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc <= 1) {
    fprintf(stderr,
            "*usage* ./spitreport -f device -I subdevices.txt -r reportname\n");
    fprintf(stderr, "\nGenerates Makefile.reportname\n");
    fprintf(stderr, "\nUsage:\n");
    fprintf(stderr,
            "\t$ ./spitreport -f /dev/test-lv -I devices.txt -r v1report\n");
    fprintf(stderr, "\t$ make -f Makefile.v1report\n");
    exit(1);
  }
  int opt = 0;
  char *device = NULL, *subdevices = NULL, *reportname = NULL;
  while ((opt = getopt(argc, argv, "f:I:r:")) != -1) {
    switch (opt) {
    case 'f':
      device = strdup(optarg);
      break;
    case 'I':
      subdevices = strdup(optarg);
      break;
    case 'r':
      reportname = strdup(optarg);
      break;
    default:
      break;
    }
  }
  fprintf(stderr, "*info* %s, %s, %s\n", device, subdevices, reportname);
  generateMakefile(device, reportname);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11ed <main+0x9d>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12b0 <main+0x160>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x49,%eax
je     1278 <main+0x128>
jmp    123f <main+0xef>
mov    -0x34(%rbp),%eax
sub    $0x66,%eax
je     1261 <main+0x111>
jmp    1250 <main+0x100>
mov    -0x34(%rbp),%eax
sub    $0x72,%eax
je     128f <main+0x13f>
jmp    12a6 <main+0x156>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    12ab <main+0x15b>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
jmp    12ab <main+0x15b>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1070 <strdup@plt>
mov    %rax,-0x30(%rbp)
jmp    12ab <main+0x15b>
jmp    12ab <main+0x15b>
jmp    120c <main+0xbc>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <generateMakefile@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    11c1 <main+0x71>
mov    0x2e71(%rip),%rbx
mov    (%rbx),%edi
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xec0(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xed0(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xec9(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xef5(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xef0(%rip),%r13
mov    0x2e1e(%rip),%r14
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11f0 <main+0xa0>
mov    (%r14),%edi
call   1070 <strdup@plt>
mov    %rax,%r12
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <getopt@plt>
cmp    $0x65,%eax
jle    1220 <main+0xd0>
cmp    $0x72,%eax
je     11e2 <main+0x92>
cmp    $0x66,%eax
jne    11f0 <main+0xa0>
mov    (%r14),%edi
call   1070 <strdup@plt>
mov    %rax,%r15
jmp    11f0 <main+0xa0>
nopl   0x0(%rax)
cmp    $0x49,%eax
je     122c <main+0xdc>
cmp    $0xffffffff,%eax
jne    11f0 <main+0xa0>
jmp    123a <main+0xea>
mov    (%r14),%edi
call   1070 <strdup@plt>
mov    %rax,(%rsp)
jmp    11f0 <main+0xa0>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    %r15,%rdx
mov    (%rsp),%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <generateMakefile@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [64 x i8] c"*usage* ./spitreport -f device -I subdevices.txt -r reportname\0A\00"
@.str.1 = [32 x i8] c"\0AGenerates Makefile.reportname\0A\00"
@.str.2 = [9 x i8] c"\0AUsage:\0A\00"
@.str.3 = [60 x i8] c"\09$ ./spitreport -f /dev/test-lv -I devices.txt -r v1report\0A\00"
@.str.4 = [30 x i8] c"\09$ make -f Makefile.v1report\0A\00"
@.str.5 = [7 x i8] c"f:I:r:\00"
@optarg = global i32 0
@.str.6 = [19 x i8] c"*info* %s, %s, %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %24
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
store i32 0, i32* %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
br label %25
25: ; preds = %42, %24
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i32 @getopt(i32 %26, i8** %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 %28, i32* %6
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %43
30: ; preds = %25
%31 = load i32, i32* %6
switch i32 %31, label %41 [
i32 102, label %32
i32 73, label %35
i32 114, label %38
]
32: ; preds = %30
%33 = load i32, i32* @optarg
%34 = call i8* @strdup(i32 %33)
store i8* %34, i8** %7
br label %42
35: ; preds = %30
%36 = load i32, i32* @optarg
%37 = call i8* @strdup(i32 %36)
store i8* %37, i8** %8
br label %42
38: ; preds = %30
%39 = load i32, i32* @optarg
%40 = call i8* @strdup(i32 %39)
store i8* %40, i8** %9
br label %42
41: ; preds = %30
br label %42
42: ; preds = %41, %38, %35, %32
br label %25
43: ; preds = %25
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %7
%46 = load i8*, i8** %8
%47 = load i8*, i8** %9
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %45, i8* %46, i8* %47)
%49 = load i8*, i8** %7
%50 = load i8*, i8** %9
%51 = call i32 @generateMakefile(i8* %49, i8* %50)
%52 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [64 x i8] c"*usage* ./spitreport -f device -I subdevices.txt -r reportname\0A\00"
@.str.1 = [32 x i8] c"\0AGenerates Makefile.reportname\0A\00"
@.str.2 = [9 x i8] c"\0AUsage:\0A\00"
@.str.3 = [60 x i8] c"\09$ ./spitreport -f /dev/test-lv -I devices.txt -r v1report\0A\00"
@.str.4 = [30 x i8] c"\09$ make -f Makefile.v1report\0A\00"
@.str.5 = [7 x i8] c"f:I:r:\00"
@optarg = global i32 0
@.str.6 = [19 x i8] c"*info* %s, %s, %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %31, %16
%17 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
switch i32 %17, label %16 [
i32 -1, label %36
i32 102, label %18
i32 73, label %25
i32 114, label %33
]
18: ; preds = %16
%19 = load i32, i32* @optarg
%20 = tail call i8* @strdup(i32 %19)
br label %21
21: ; preds = %2, %18
%22 = phi i8* [ %20, %18 ], [ null, %2 ]
%23 = phi i8* [ %29, %18 ], [ null, %2 ]
%24 = phi i8* [ %32, %18 ], [ null, %2 ]
br label %28
25: ; preds = %16
%26 = load i32, i32* @optarg
%27 = tail call i8* @strdup(i32 %26)
br label %28
28: ; preds = %21, %25
%29 = phi i8* [ %23, %21 ], [ %27, %25 ]
%30 = phi i8* [ %24, %21 ], [ %32, %25 ]
br label %31
31: ; preds = %28, %33
%32 = phi i8* [ %30, %28 ], [ %35, %33 ]
br label %16
33: ; preds = %16
%34 = load i32, i32* @optarg
%35 = tail call i8* @strdup(i32 %34)
br label %31
36: ; preds = %16
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %22, i8* %29, i8* %32)
%39 = tail call i32 @generateMakefile(i8* %22, i8* %32)
%40 = tail call i32 @exit(i32 0)
unreachable
}