#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 LOG_CONS;
int LOG_PID;
int /*<<< orphan*/ LOG_USER;
int daemonize();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int parse_args(int argc, char *argv[]) {
  if (argc >= 2) {
    const char *help_msg =
        "usage :"
        "\n\t-h [--help] : print the usage help message"
        "\n\t-d [--daemonize]: start the program as a daemon";
    if (!strcmp(argv[1], "-d") || !strcmp(argv[1], "--daemonize"))
      return daemonize();
    if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
      puts(help_msg);
      return 1;
    }
    fprintf(stderr, "Unknown argument %s\n", argv[1]);
    fputs(help_msg, stderr);
    return 1;
  }
  openlog("usbwall", LOG_CONS | LOG_PID, LOG_USER);
  return 0;
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1257 <parse_args+0xf7>
lea    0xe80(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xed2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     11be <parse_args+0x5e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11cd <parse_args+0x6d>
mov    $0x0,%al
call   1040 <daemonize@plt>
mov    %eax,-0x4(%rbp)
jmp    1285 <parse_args+0x125>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe98(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1207 <parse_args+0xa7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    121c <parse_args+0xbc>
mov    -0x18(%rbp),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <parse_args+0x125>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe4a(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <parse_args+0x125>
mov    0x2d6a(%rip),%rax
mov    (%rax),%esi
mov    0x2d71(%rip),%rax
or     (%rax),%esi
mov    0x2d78(%rip),%rax
mov    (%rax),%edx
lea    0xe1a(%rip),%rdi
call   1080 <openlog@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11f8 <parse_args+0x98>
mov    0x8(%rsi),%rbx
lea    0xeed(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1229 <parse_args+0xc9>
lea    0xed9(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1229 <parse_args+0xc9>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1237 <parse_args+0xd7>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1237 <parse_args+0xd7>
mov    0x2e00(%rip),%r14
mov    (%r14),%edi
lea    0xea4(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    (%r14),%esi
lea    0xe14(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%eax
jmp    1221 <parse_args+0xc1>
mov    0x2dc9(%rip),%rax
mov    0x2dd2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dd7(%rip),%rax
mov    (%rax),%edx
lea    0xe79(%rip),%rdi
call   1080 <openlog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <daemonize@plt>
lea    0xdc2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    1221 <parse_args+0xc1>

LLVM IR (-O0):
@.str = [101 x i8] c"usage :\0A\09-h [--help] : print the usage help message\0A\09-d [--daemonize]: start the program as a daemon\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [12 x i8] c"--daemonize\00"
@.str.3 = [3 x i8] c"-h\00"
@.str.4 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.5 = [21 x i8] c"Unknown argument %s\0A\00"
@.str.6 = [8 x i8] c"usbwall\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_USER = global i32 0
define i32 @parse_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 2
br i1 %8, label %9, label %47
9: ; preds = %2
store i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %15, %9
%22 = call i32 (...) @daemonize()
store i32 %22, i32* %3
br label %53
23: ; preds = %15
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %29, %23
%36 = load i8*, i8** %6
%37 = call i32 @puts(i8* %36)
store i32 1, i32* %3
br label %53
38: ; preds = %29
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = load i8*, i8** %6
%45 = load i32, i32* @stderr
%46 = call i32 @fputs(i8* %44, i32 %45)
store i32 1, i32* %3
br label %53
47: ; preds = %2
%48 = load i32, i32* @LOG_CONS
%49 = load i32, i32* @LOG_PID
%50 = or i32 %48, %49
%51 = load i32, i32* @LOG_USER
%52 = call i32 @openlog(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %50, i32 %51)
store i32 0, i32* %3
br label %53
53: ; preds = %47, %38, %35, %21
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [101 x i8] c"usage :\0A\09-h [--help] : print the usage help message\0A\09-d [--daemonize]: start the program as a daemon\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [12 x i8] c"--daemonize\00"
@.str.3 = [3 x i8] c"-h\00"
@.str.4 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.5 = [21 x i8] c"Unknown argument %s\0A\00"
@.str.6 = [8 x i8] c"usbwall\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_USER = global i32 0
define i32 @parse_args(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %27
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9, %4
%13 = tail call i32 (...) @daemonize()
br label %33
14: ; preds = %9
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17, %14
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([101 x i8], [101 x i8]* @.str, i64 0, i64 0))
br label %33
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%25 = load i32, i32* @stderr
%26 = tail call i32 @fputs(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %33
27: ; preds = %2
%28 = load i32, i32* @LOG_CONS
%29 = load i32, i32* @LOG_PID
%30 = or i32 %29, %28
%31 = load i32, i32* @LOG_USER
%32 = tail call i32 @openlog(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %30, i32 %31)
br label %33
33: ; preds = %12, %20, %22, %27
%34 = phi i32 [ 0, %27 ], [ 1, %22 ], [ 1, %20 ], [ %13, %12 ]
ret i32 %34
}