#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 *, char *);
void parse_powersave(int argc, char **argv, int *option, int *opt_mode,
                     int *bad_arg) {
  if (argc > 1 || *option)
    *bad_arg = 1;
  *option = 1;
  if (argc == 1) {
    if (strcmp(argv[0], "on") == 0)
      *opt_mode = 1;
    else if (strcmp(argv[0], "vsync") == 0)
      *opt_mode = 1;
    else if (strcmp(argv[0], "hsync") == 0)
      *opt_mode = 2;
    else if (strcmp(argv[0], "powerdown") == 0)
      *opt_mode = 3;
    else if (strcmp(argv[0], "off") == 0)
      *opt_mode = 0;
    else
      *bad_arg = 1;
  } else {
    *opt_mode = 0;
  }
}


x86 assembly (clang, -O0):
<parse_powersave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpl   $0x1,-0x4(%rbp)
jg     1142 <parse_powersave+0x32>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     114c <parse_powersave+0x3c>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
cmpl   $0x1,-0x4(%rbp)
jne    125f <parse_powersave+0x14f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe92(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118c <parse_powersave+0x7c>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    125a <parse_powersave+0x14a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b8 <parse_powersave+0xa8>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    1255 <parse_powersave+0x145>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe43(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <parse_powersave+0xd4>
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
jmp    1250 <parse_powersave+0x140>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe1d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1210 <parse_powersave+0x100>
mov    -0x20(%rbp),%rax
movl   $0x3,(%rax)
jmp    124b <parse_powersave+0x13b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdfb(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <parse_powersave+0x12c>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    1246 <parse_powersave+0x136>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    124b <parse_powersave+0x13b>
jmp    1250 <parse_powersave+0x140>
jmp    1255 <parse_powersave+0x145>
jmp    125a <parse_powersave+0x14a>
jmp    1269 <parse_powersave+0x159>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_powersave>:
push   %r15
push   %r14
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1128 <parse_powersave+0x18>
cmpl   $0x0,(%rdx)
je     112f <parse_powersave+0x1f>
movl   $0x1,(%r14)
movl   $0x1,(%rdx)
cmp    $0x1,%edi
jne    11a7 <parse_powersave+0x97>
mov    (%rbx),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b0 <parse_powersave+0xa0>
mov    (%rbx),%rdi
lea    0xeab(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b0 <parse_powersave+0xa0>
mov    (%rbx),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11bd <parse_powersave+0xad>
mov    (%rbx),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c6 <parse_powersave+0xb6>
mov    (%rbx),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a7 <parse_powersave+0x97>
movl   $0x1,(%r14)
jmp    11b7 <parse_powersave+0xa7>
movl   $0x0,(%r15)
jmp    11b7 <parse_powersave+0xa7>
movl   $0x1,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret
movl   $0x2,(%r15)
jmp    11b7 <parse_powersave+0xa7>
movl   $0x3,(%r15)
jmp    11b7 <parse_powersave+0xa7>

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [6 x i8] c"vsync\00"
@.str.2 = [6 x i8] c"hsync\00"
@.str.3 = [10 x i8] c"powerdown\00"
@.str.4 = [4 x i8] c"off\00"
define void @parse_powersave(i32 %0, i8** %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 1
br i1 %12, label %17, label %13
13: ; preds = %5
%14 = load i32*, i32** %8
%15 = load i32, i32* %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13, %5
%18 = load i32*, i32** %10
store i32 1, i32* %18
br label %19
19: ; preds = %17, %13
%20 = load i32*, i32** %8
store i32 1, i32* %20
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %70
23: ; preds = %19
%24 = load i8**, i8*** %7
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = load i32*, i32** %9
store i32 1, i32* %30
br label %69
31: ; preds = %23
%32 = load i8**, i8*** %7
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = load i32*, i32** %9
store i32 1, i32* %38
br label %68
39: ; preds = %31
%40 = load i8**, i8*** %7
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = load i32*, i32** %9
store i32 2, i32* %46
br label %67
47: ; preds = %39
%48 = load i8**, i8*** %7
%49 = getelementptr inbounds i8*, i8** %48, i64 0
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = load i32*, i32** %9
store i32 3, i32* %54
br label %66
55: ; preds = %47
%56 = load i8**, i8*** %7
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %55
%62 = load i32*, i32** %9
store i32 0, i32* %62
br label %65
63: ; preds = %55
%64 = load i32*, i32** %10
store i32 1, i32* %64
br label %65
65: ; preds = %63, %61
br label %66
66: ; preds = %65, %53
br label %67
67: ; preds = %66, %45
br label %68
68: ; preds = %67, %37
br label %69
69: ; preds = %68, %29
br label %72
70: ; preds = %19
%71 = load i32*, i32** %9
store i32 0, i32* %71
br label %72
72: ; preds = %70, %69
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [6 x i8] c"vsync\00"
@.str.2 = [6 x i8] c"hsync\00"
@.str.3 = [10 x i8] c"powerdown\00"
@.str.4 = [4 x i8] c"off\00"
define void @parse_powersave(i32 %0, i8** nocapture %1, i32* nocapture %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = icmp sgt i32 %0, 1
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %7, %5
store i32 1, i32* %4
br label %11
11: ; preds = %10, %7
store i32 1, i32* %2
%12 = icmp eq i32 %0, 1
br i1 %12, label %13, label %39
13: ; preds = %11
%14 = load i8*, i8** %1
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 1, i32* %3
br label %40
18: ; preds = %13
%19 = load i8*, i8** %1
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 1, i32* %3
br label %40
23: ; preds = %18
%24 = load i8*, i8** %1
%25 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 2, i32* %3
br label %40
28: ; preds = %23
%29 = load i8*, i8** %1
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 3, i32* %3
br label %40
33: ; preds = %28
%34 = load i8*, i8** %1
%35 = tail call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 0, i32* %3
br label %40
38: ; preds = %33
store i32 1, i32* %4
br label %40
39: ; preds = %11
store i32 0, i32* %3
br label %40
40: ; preds = %17, %27, %37, %38, %32, %22, %39
ret void
}