#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 handle_connect(char *);
int handle_disconnect(char *);
scalar_t__ strcmp(char *, char *);
int usage();
int main(int argc, char *argv[]) {
  if (argc != 3) {
    return usage();
  }
  char *device = argv[1];
  char *event = argv[2];
  if (strcmp(event, "CONNECTED") == 0)
    return handle_connect(device);
  else if (strcmp(event, "DISCONNECTED") == 0)
    return handle_disconnect(device);
  return usage();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     116f <main+0x2f>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <main+0xac>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b2 <main+0x72>
mov    -0x18(%rbp),%rdi
call   1050 <handle_connect@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <main+0xac>
mov    -0x20(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11dd <main+0x9d>
mov    -0x18(%rbp),%rdi
call   1030 <handle_disconnect@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <main+0xac>
jmp    11e2 <main+0xa2>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1179 <main+0x39>
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rbx
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1187 <main+0x47>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1196 <main+0x56>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <usage@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <handle_connect@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <handle_disconnect@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"CONNECTED\00"
@.str.1 = [13 x i8] c"DISCONNECTED\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
store i32 %11, i32* %3
br label %35
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %12
%23 = load i8*, i8** %6
%24 = call i32 @handle_connect(i8* %23)
store i32 %24, i32* %3
br label %35
25: ; preds = %12
%26 = load i8*, i8** %7
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = call i32 @handle_disconnect(i8* %30)
store i32 %31, i32* %3
br label %35
32: ; preds = %25
br label %33
33: ; preds = %32
%34 = call i32 (...) @usage()
store i32 %34, i32* %3
br label %35
35: ; preds = %33, %29, %22, %10
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [10 x i8] c"CONNECTED\00"
@.str.1 = [13 x i8] c"DISCONNECTED\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %22
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @handle_connect(i8* %8)
br label %22
15: ; preds = %6
%16 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @handle_disconnect(i8* %8)
br label %22
20: ; preds = %15
%21 = tail call i32 (...) @usage()
br label %22
22: ; preds = %13, %18, %20, %4
%23 = phi i32 [ %5, %4 ], [ %14, %13 ], [ %19, %18 ], [ %21, %20 ]
ret i32 %23
}