#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 */
scalar_t__ strcmp(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlower(char *);
int c_set_status(int argc, char *argv[]) {
  extern int c_set_status_bits(unsigned char);
  if (strcmp("newbattery", strlower(argv[1])) == 0) {
    return c_set_status_bits(2);
  } else if (strcmp("purge", strlower(argv[1])) == 0) {
    return c_set_status_bits(4);
  } else if (strcmp("clear", strlower(argv[1])) == 0) {
    return c_set_status_bits(1);
  } else if (strcmp("reserved", strlower(argv[1])) == 0) {
    return c_set_status_bits(8);
  }
  return 0;
}


x86 assembly (clang, -O0):
<c_set_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlower@plt>
mov    %eax,%esi
lea    0xeab(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1176 <c_set_status+0x46>
mov    $0x2,%edi
call   1040 <c_set_status_bits@plt>
mov    %eax,-0x4(%rbp)
jmp    1231 <c_set_status+0x101>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlower@plt>
mov    %eax,%esi
lea    0xe7f(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ad <c_set_status+0x7d>
mov    $0x4,%edi
call   1040 <c_set_status_bits@plt>
mov    %eax,-0x4(%rbp)
jmp    1231 <c_set_status+0x101>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlower@plt>
mov    %eax,%esi
lea    0xe4e(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <c_set_status+0xb4>
mov    $0x1,%edi
call   1040 <c_set_status_bits@plt>
mov    %eax,-0x4(%rbp)
jmp    1231 <c_set_status+0x101>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlower@plt>
mov    %eax,%esi
lea    0xe1d(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121b <c_set_status+0xeb>
mov    $0x8,%edi
call   1040 <c_set_status_bits@plt>
mov    %eax,-0x4(%rbp)
jmp    1231 <c_set_status+0x101>
jmp    1220 <c_set_status+0xf0>
jmp    1225 <c_set_status+0xf5>
jmp    122a <c_set_status+0xfa>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_set_status>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <strlower@plt>
lea    0xebc(%rip),%rdi
mov    %eax,%esi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a8 <c_set_status+0x78>
mov    0x8(%rbx),%rdi
call   1050 <strlower@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ac <c_set_status+0x7c>
mov    0x8(%rbx),%rdi
call   1050 <strlower@plt>
lea    0xe95(%rip),%rdi
mov    %eax,%esi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b0 <c_set_status+0x80>
mov    0x8(%rbx),%rdi
call   1050 <strlower@plt>
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b4 <c_set_status+0x84>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x2,%al
jmp    11b6 <c_set_status+0x86>
mov    $0x4,%al
jmp    11b6 <c_set_status+0x86>
mov    $0x1,%al
jmp    11b6 <c_set_status+0x86>
mov    $0x8,%al
movzbl %al,%edi
pop    %rbx
jmp    1040 <c_set_status_bits@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"newbattery\00"
@.str.1 = [6 x i8] c"purge\00"
@.str.2 = [6 x i8] c"clear\00"
@.str.3 = [9 x i8] c"reserved\00"
define i32 @c_set_status(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 i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @strlower(i8* %8)
%10 = call i64 @strcmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @c_set_status_bits(i8 zeroext 2)
store i32 %13, i32* %3
br label %45
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strlower(i8* %17)
%19 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 @c_set_status_bits(i8 zeroext 4)
store i32 %22, i32* %3
br label %45
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @strlower(i8* %26)
%28 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 @c_set_status_bits(i8 zeroext 1)
store i32 %31, i32* %3
br label %45
32: ; preds = %23
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strlower(i8* %35)
%37 = call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 @c_set_status_bits(i8 zeroext 8)
store i32 %40, i32* %3
br label %45
41: ; preds = %32
br label %42
42: ; preds = %41
br label %43
43: ; preds = %42
br label %44
44: ; preds = %43
store i32 0, i32* %3
br label %45
45: ; preds = %44, %39, %30, %21, %12
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [11 x i8] c"newbattery\00"
@.str.1 = [6 x i8] c"purge\00"
@.str.2 = [6 x i8] c"clear\00"
@.str.3 = [9 x i8] c"reserved\00"
define i32 @c_set_status(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @strlower(i8* %4)
%6 = tail call i64 @strcmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %23, label %8
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = tail call i32 @strlower(i8* %9)
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = tail call i32 @strlower(i8* %14)
%16 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = tail call i32 @strlower(i8* %19)
%21 = tail call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18, %13, %8, %2
%24 = phi i8 [ 2, %2 ], [ 4, %8 ], [ 1, %13 ], [ 8, %18 ]
%25 = tail call i32 @c_set_status_bits(i8 zeroext %24)
br label %26
26: ; preds = %23, %18
%27 = phi i32 [ 0, %18 ], [ %25, %23 ]
ret i32 %27
}