#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*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int write(int, char *, int);
int qxdmlog_main(int argc, char *argv[]) {
  int fd, r, bytes = 0;
  char devname[] = "/sys/devices/platform/DIAG.0/qxdm2sd";
  char buffer[8];
  fd = open(devname, O_WRONLY);
  if (fd < 0) {
    fprintf(stderr, "failed to open qxdm2sd - %s\n", strerror(errno));
    return -1;
  }
  if (!strcmp(argv[1], "start")) {
    bytes = sprintf(buffer, "%d\n", 1);
    r = write(fd, buffer, bytes);
    if (r != bytes) {
      fprintf(stderr, "failed to write qxdm2sd (%d) %s\n", r, strerror(errno));
      return -1;
    } else {
      printf("Start QXDM log to SD.\n");
    }
  } else if (!strcmp(argv[1], "stop")) {
    bytes = sprintf(buffer, "%d\n", 0);
    r = write(fd, buffer, bytes);
    if (r != bytes) {
      fprintf(stderr, "failed to write qxdm2sd (%d) %s\n", r, strerror(errno));
      return -1;
    } else {
      printf("Stop QXDM log to SD.\n");
    }
  } else if (!strcmp(argv[1], "fstart")) {
    bytes = sprintf(buffer, "%d\n", 2);
    r = write(fd, buffer, bytes);
    if (r != bytes) {
      fprintf(stderr, "failed to write qxdm2sd (%d) %s\n", r, strerror(errno));
      return -1;
    } else {
      printf("Start capture filter to SD.\n");
    }
  } else if (!strcmp(argv[1], "fstop")) {
    bytes = sprintf(buffer, "%d\n", 3);
    r = write(fd, buffer, bytes);
    if (r != bytes) {
      fprintf(stderr, "failed to write qxdm2sd (%d) %s\n", r, strerror(errno));
      return -1;
    } else {
      printf("Stop capture filter to SD.\n");
    }
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<qxdmlog_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x25,%edx
call   1080 <memcpy@plt>
lea    -0x50(%rbp),%rdi
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1217 <qxdmlog_main+0x87>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%rdx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14ce <qxdmlog_main+0x33e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12be <qxdmlog_main+0x12e>
lea    -0x58(%rbp),%rdi
lea    0xe03(%rip),%rsi
mov    $0x1,%edx
call   10a0 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     12ad <qxdmlog_main+0x11d>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%edx
mov    %rax,%rcx
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14ce <qxdmlog_main+0x33e>
lea    0xdb3(%rip),%rdi
call   1040 <printf@plt>
jmp    14bf <qxdmlog_main+0x32f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdec(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1362 <qxdmlog_main+0x1d2>
lea    -0x58(%rbp),%rdi
lea    0xd5c(%rip),%rsi
xor    %edx,%edx
call   10a0 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1351 <qxdmlog_main+0x1c1>
mov    0x2ccb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%edx
mov    %rax,%rcx
lea    0xd08(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14ce <qxdmlog_main+0x33e>
lea    0xd26(%rip),%rdi
call   1040 <printf@plt>
jmp    14ba <qxdmlog_main+0x32a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd23(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1409 <qxdmlog_main+0x279>
lea    -0x58(%rbp),%rdi
lea    0xcb8(%rip),%rsi
mov    $0x2,%edx
call   10a0 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     13f8 <qxdmlog_main+0x268>
mov    0x2c24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%edx
mov    %rax,%rcx
lea    0xc61(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14ce <qxdmlog_main+0x33e>
lea    0xc9c(%rip),%rdi
call   1040 <printf@plt>
jmp    14b5 <qxdmlog_main+0x325>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xca0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    14b0 <qxdmlog_main+0x320>
lea    -0x58(%rbp),%rdi
lea    0xc11(%rip),%rsi
mov    $0x3,%edx
call   10a0 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     149f <qxdmlog_main+0x30f>
mov    0x2b7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x2b63(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%edx
mov    %rax,%rcx
lea    0xbba(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14ce <qxdmlog_main+0x33e>
lea    0xc18(%rip),%rdi
call   1040 <printf@plt>
jmp    14b0 <qxdmlog_main+0x320>
jmp    14b5 <qxdmlog_main+0x325>
jmp    14ba <qxdmlog_main+0x32a>
jmp    14bf <qxdmlog_main+0x32f>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qxdmlog_main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
movaps 0xe7e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe62(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x6473326d647871,%rax
mov    %rax,0x2d(%rsp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   1080 <open@plt>
test   %eax,%eax
js     126a <qxdmlog_main+0xea>
mov    %eax,%ebp
mov    0x8(%rbx),%rbx
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1299 <qxdmlog_main+0x119>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12cd <qxdmlog_main+0x14d>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12fe <qxdmlog_main+0x17e>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1335 <qxdmlog_main+0x1b5>
lea    0xe0c(%rip),%rsi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0x3,%edx
call   1090 <sprintf@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    %ebx,%eax
jne    1340 <qxdmlog_main+0x1c0>
lea    0xe56(%rip),%rdi
jmp    1330 <qxdmlog_main+0x1b0>
mov    0x2d6f(%rip),%rax
mov    (%rax),%ebx
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd9d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1370 <qxdmlog_main+0x1f0>
lea    0xda2(%rip),%rsi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0x1,%edx
call   1090 <sprintf@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    %ebx,%eax
jne    1340 <qxdmlog_main+0x1c0>
lea    0xda9(%rip),%rdi
jmp    1330 <qxdmlog_main+0x1b0>
lea    0xd6e(%rip),%rsi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %edx,%edx
call   1090 <sprintf@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    %ebx,%eax
jne    1340 <qxdmlog_main+0x1c0>
lea    0xd8e(%rip),%rdi
jmp    1330 <qxdmlog_main+0x1b0>
lea    0xd3d(%rip),%rsi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0x2,%edx
call   1090 <sprintf@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    %ebx,%eax
jne    1340 <qxdmlog_main+0x1c0>
lea    0xd6f(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
jmp    1375 <qxdmlog_main+0x1f5>
mov    %eax,%r14d
mov    0x2c96(%rip),%rax
mov    (%rax),%ebx
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xce5(%rip),%rsi
mov    %ebx,%edi
mov    %r14d,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.qxdmlog_main.devname = [37 x i8] c"/sys/devices/platform/DIAG.0/qxdm2sd\00"
@O_WRONLY = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"failed to open qxdm2sd - %s\0A\00"
@errno = global i32 0
@.str.1 = [6 x i8] c"start\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [33 x i8] c"failed to write qxdm2sd (%d) %s\0A\00"
@.str.4 = [23 x i8] c"Start QXDM log to SD.\0A\00"
@.str.5 = [5 x i8] c"stop\00"
@.str.6 = [22 x i8] c"Stop QXDM log to SD.\0A\00"
@.str.7 = [7 x i8] c"fstart\00"
@.str.8 = [29 x i8] c"Start capture filter to SD.\0A\00"
@.str.9 = [6 x i8] c"fstop\00"
@.str.10 = [28 x i8] c"Stop capture filter to SD.\0A\00"
define i32 @qxdmlog_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [37 x i8]
%10 = alloca [8 x i8]
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%11 = bitcast [37 x i8]* %9 to i8*
%12 = getelementptr inbounds [37 x i8], [37 x i8]* %9, i64 0, i64 0
%13 = load i32, i32* @O_WRONLY
%14 = call i32 @open(i8* %12, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 -1, i32* %3
br label %128
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %47, label %28
28: ; preds = %22
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%30 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1)
store i32 %30, i32* %8
%31 = load i32, i32* %6
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%33 = load i32, i32* %8
%34 = call i32 @write(i32 %31, i8* %32, i32 %33)
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = icmp ne i32 %35, %36
br i1 %37, label %38, label %44
38: ; preds = %28
%39 = load i32, i32* @stderr
%40 = load i32, i32* %7
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %40, i8* %42)
store i32 -1, i32* %3
br label %128
44: ; preds = %28
%45 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44
br label %125
47: ; preds = %22
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 @strcmp(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
br i1 %52, label %72, label %53
53: ; preds = %47
%54 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%55 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 0)
store i32 %55, i32* %8
%56 = load i32, i32* %6
%57 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%58 = load i32, i32* %8
%59 = call i32 @write(i32 %56, i8* %57, i32 %58)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = load i32, i32* %8
%62 = icmp ne i32 %60, %61
br i1 %62, label %63, label %69
63: ; preds = %53
%64 = load i32, i32* @stderr
%65 = load i32, i32* %7
%66 = load i32, i32* @errno
%67 = call i8* @strerror(i32 %66)
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %65, i8* %67)
store i32 -1, i32* %3
br label %128
69: ; preds = %53
%70 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %71
71: ; preds = %69
br label %124
72: ; preds = %47
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 1
%75 = load i8*, i8** %74
%76 = call i32 @strcmp(i8* %75, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%77 = icmp ne i32 %76, 0
br i1 %77, label %97, label %78
78: ; preds = %72
%79 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%80 = call i32 @sprintf(i8* %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 2)
store i32 %80, i32* %8
%81 = load i32, i32* %6
%82 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%83 = load i32, i32* %8
%84 = call i32 @write(i32 %81, i8* %82, i32 %83)
store i32 %84, i32* %7
%85 = load i32, i32* %7
%86 = load i32, i32* %8
%87 = icmp ne i32 %85, %86
br i1 %87, label %88, label %94
88: ; preds = %78
%89 = load i32, i32* @stderr
%90 = load i32, i32* %7
%91 = load i32, i32* @errno
%92 = call i8* @strerror(i32 %91)
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %90, i8* %92)
store i32 -1, i32* %3
br label %128
94: ; preds = %78
%95 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %96
96: ; preds = %94
br label %123
97: ; preds = %72
%98 = load i8**, i8*** %5
%99 = getelementptr inbounds i8*, i8** %98, i64 1
%100 = load i8*, i8** %99
%101 = call i32 @strcmp(i8* %100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%102 = icmp ne i32 %101, 0
br i1 %102, label %122, label %103
103: ; preds = %97
%104 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%105 = call i32 @sprintf(i8* %104, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
store i32 %105, i32* %8
%106 = load i32, i32* %6
%107 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%108 = load i32, i32* %8
%109 = call i32 @write(i32 %106, i8* %107, i32 %108)
store i32 %109, i32* %7
%110 = load i32, i32* %7
%111 = load i32, i32* %8
%112 = icmp ne i32 %110, %111
br i1 %112, label %113, label %119
113: ; preds = %103
%114 = load i32, i32* @stderr
%115 = load i32, i32* %7
%116 = load i32, i32* @errno
%117 = call i8* @strerror(i32 %116)
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %115, i8* %117)
store i32 -1, i32* %3
br label %128
119: ; preds = %103
%120 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
br label %121
121: ; preds = %119
br label %122
122: ; preds = %121, %97
br label %123
123: ; preds = %122, %96
br label %124
124: ; preds = %123, %71
br label %125
125: ; preds = %124, %46
%126 = load i32, i32* %6
%127 = call i32 @close(i32 %126)
store i32 0, i32* %3
br label %128
128: ; preds = %125, %113, %88, %63, %38, %17
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
@__const.qxdmlog_main.devname = [37 x i8] c"/sys/devices/platform/DIAG.0/qxdm2sd\00"
@O_WRONLY = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"failed to open qxdm2sd - %s\0A\00"
@errno = global i32 0
@.str.1 = [6 x i8] c"start\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [33 x i8] c"failed to write qxdm2sd (%d) %s\0A\00"
@.str.5 = [5 x i8] c"stop\00"
@.str.7 = [7 x i8] c"fstart\00"
@.str.9 = [6 x i8] c"fstop\00"
@str = [22 x i8] c"Start QXDM log to SD.\00"
@str.11 = [21 x i8] c"Stop QXDM log to SD.\00"
@str.12 = [28 x i8] c"Start capture filter to SD.\00"
@str.13 = [27 x i8] c"Stop capture filter to SD.\00"
define i32 @qxdmlog_main(i32 %0, i8** nocapture %1) {
%3 = alloca [37 x i8]
%4 = alloca [8 x i8]
%5 = getelementptr inbounds [37 x i8], [37 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @open(i8* %5, i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %70
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1)
%22 = call i32 @write(i32 %8, i8* %6, i32 %21)
%23 = icmp eq i32 %22, %21
br i1 %23, label %65, label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i32, i32* @errno
%27 = tail call i8* @strerror(i32 %26)
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %22, i8* %27)
br label %70
29: ; preds = %15
%30 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 0)
%34 = call i32 @write(i32 %8, i8* %6, i32 %33)
%35 = icmp eq i32 %34, %33
br i1 %35, label %65, label %36
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = tail call i8* @strerror(i32 %38)
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %34, i8* %39)
br label %70
41: ; preds = %29
%42 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %41
%45 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 2)
%46 = call i32 @write(i32 %8, i8* %6, i32 %45)
%47 = icmp eq i32 %46, %45
br i1 %47, label %65, label %48
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = load i32, i32* @errno
%51 = tail call i8* @strerror(i32 %50)
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %46, i8* %51)
br label %70
53: ; preds = %41
%54 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %68
56: ; preds = %53
%57 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%58 = call i32 @write(i32 %8, i8* %6, i32 %57)
%59 = icmp eq i32 %58, %57
br i1 %59, label %65, label %60
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = tail call i8* @strerror(i32 %62)
%64 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %58, i8* %63)
br label %70
65: ; preds = %56, %44, %32, %20
%66 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0), %20 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0), %32 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.12, i64 0, i64 0), %44 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0), %56 ]
%67 = tail call i32 @puts(i8* dereferenceable(1) %66)
br label %68
68: ; preds = %65, %53
%69 = tail call i32 @close(i32 %8)
br label %70
70: ; preds = %68, %60, %48, %36, %24, %10
%71 = phi i32 [ -1, %10 ], [ 0, %68 ], [ -1, %60 ], [ -1, %48 ], [ -1, %36 ], [ -1, %24 ]
ret i32 %71
}