#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*/ strcmp(char *, char *);
int cmdproc(int argc, char *argv[]) {
  if (argc < 2)
    return 0;
  if (!strcmp(argv[1], "kill"))
    return 3;
  if (argc < 3)
    return 0;
  if (!strcmp(argv[1], "create"))
    return 1;
  else if (!strcmp(argv[1], "switch"))
    return 2;
  return 0;
}


x86 assembly (clang, -O0):
<cmdproc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1135 <cmdproc+0x25>
movl   $0x0,-0x4(%rbp)
jmp    11d2 <cmdproc+0xc2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    115e <cmdproc+0x4e>
movl   $0x3,-0x4(%rbp)
jmp    11d2 <cmdproc+0xc2>
cmpl   $0x3,-0x8(%rbp)
jge    1174 <cmdproc+0x64>
movl   $0x0,-0x4(%rbp)
jmp    11d2 <cmdproc+0xc2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119d <cmdproc+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    11d2 <cmdproc+0xc2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c6 <cmdproc+0xb6>
movl   $0x2,-0x4(%rbp)
jmp    11d2 <cmdproc+0xc2>
jmp    11cb <cmdproc+0xbb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmdproc>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
cmp    $0x2,%edi
jl     1172 <cmdproc+0x62>
mov    %edi,%ebp
mov    0x8(%rsi),%r14
lea    0xed8(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1166 <cmdproc+0x56>
cmp    $0x3,%ebp
jb     1172 <cmdproc+0x62>
lea    0xec5(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     116d <cmdproc+0x5d>
lea    0xeb9(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
add    %ebx,%ebx
jmp    1172 <cmdproc+0x62>
mov    $0x3,%ebx
jmp    1172 <cmdproc+0x62>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"kill\00"
@.str.1 = [7 x i8] c"create\00"
@.str.2 = [7 x i8] c"switch\00"
define i32 @cmdproc(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 0, i32* %3
br label %36
9: ; preds = %2
%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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %9
store i32 3, i32* %3
br label %36
16: ; preds = %9
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 0, i32* %3
br label %36
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %20
store i32 1, i32* %3
br label %36
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %27
store i32 2, i32* %3
br label %36
34: ; preds = %27
br label %35
35: ; preds = %34
store i32 0, i32* %3
br label %36
36: ; preds = %35, %33, %26, %19, %15, %8
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [5 x i8] c"kill\00"
@.str.1 = [7 x i8] c"create\00"
@.str.2 = [7 x i8] c"switch\00"
define i32 @cmdproc(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %18, label %4
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(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %4
%10 = icmp ult i32 %0, 3
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i32 2, i32 0
br label %18
18: ; preds = %14, %11, %9, %4, %2
%19 = phi i32 [ 0, %2 ], [ 3, %4 ], [ 0, %9 ], [ 1, %11 ], [ %17, %14 ]
ret i32 %19
}