#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*/ exit(int);
int /*<<< orphan*/ mount(char *, char *, char *, int /*<<< orphan*/, char *);
scalar_t__ strcmp(char *, char *);
int switch_gpu(int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int status = 0;
  if (argc == 2) {
    mount("efivarfs", "/sys/firmware/efi/efivars", "efivarfs", 0, "");
    if (strcmp(argv[1], "-i") == 0 || strcmp(argv[1], "--integrated") == 0) {
      status = switch_gpu(1);
    } else if (strcmp(argv[1], "-d") == 0 ||
               strcmp(argv[1], "--dedicated") == 0) {
      status = switch_gpu(0);
    } else {
      usage(argv[0]);
    }
  } else {
    usage(argv[0]);
  }
  exit(status);
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1245 <main+0xf5>
lea    0xe82(%rip),%rdx
lea    0xe84(%rip),%rsi
xor    %ecx,%ecx
lea    0xea7(%rip),%r8
mov    %rdx,%rdi
call   1030 <mount@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11d2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <main+0x94>
mov    $0x1,%edi
call   1070 <switch_gpu@plt>
mov    %eax,-0x14(%rbp)
jmp    1240 <main+0xf0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1220 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe25(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122f <main+0xdf>
xor    %edi,%edi
call   1070 <switch_gpu@plt>
mov    %eax,-0x14(%rbp)
jmp    123b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
jmp    1240 <main+0xf0>
jmp    1251 <main+0x101>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11e5 <main+0x95>
lea    0xea5(%rip),%rsi
lea    0xe95(%rip),%rdi
lea    0xec3(%rip),%r8
mov    %rdi,%rdx
xor    %ecx,%ecx
call   1030 <mount@plt>
mov    0x8(%rbx),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a6 <main+0x56>
mov    0x8(%rbx),%rdi
lea    0xe8a(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11ad <main+0x5d>
mov    $0x1,%edi
jmp    11d9 <main+0x89>
mov    0x8(%rbx),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d7 <main+0x87>
mov    0x8(%rbx),%rdi
lea    0xe69(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11e5 <main+0x95>
xor    %edi,%edi
call   1070 <switch_gpu@plt>
mov    %eax,%edi
call   1060 <exit@plt>
mov    (%rbx),%rdi
call   1050 <usage@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"efivarfs\00"
@.str.1 = [26 x i8] c"/sys/firmware/efi/efivars\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"-i\00"
@.str.4 = [13 x i8] c"--integrated\00"
@.str.5 = [3 x i8] c"-d\00"
@.str.6 = [12 x i8] c"--dedicated\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %45
9: ; preds = %2
%10 = call i32 @mount(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %9
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16, %9
%23 = call i32 @switch_gpu(i32 1)
store i32 %23, i32* %6
br label %44
24: ; preds = %16
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %30, %24
%37 = call i32 @switch_gpu(i32 0)
store i32 %37, i32* %6
br label %43
38: ; preds = %30
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 @usage(i8* %41)
br label %43
43: ; preds = %38, %36
br label %44
44: ; preds = %43, %22
br label %50
45: ; preds = %2
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 @usage(i8* %48)
br label %50
50: ; preds = %45, %44
%51 = load i32, i32* %6
%52 = call i32 @exit(i32 %51)
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"efivarfs\00"
@.str.1 = [26 x i8] c"/sys/firmware/efi/efivars\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"-i\00"
@.str.4 = [13 x i8] c"--integrated\00"
@.str.5 = [3 x i8] c"-d\00"
@.str.6 = [12 x i8] c"--dedicated\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = tail call i32 @mount(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = load i8*, i8** %6
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10, %4
%15 = tail call i32 @switch_gpu(i32 1)
br label %32
16: ; preds = %10
%17 = load i8*, i8** %6
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i8*, i8** %6
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20, %16
%25 = tail call i32 @switch_gpu(i32 0)
br label %32
26: ; preds = %20
%27 = load i8*, i8** %1
%28 = tail call i32 @usage(i8* %27)
br label %32
29: ; preds = %2
%30 = load i8*, i8** %1
%31 = tail call i32 @usage(i8* %30)
br label %32
32: ; preds = %14, %26, %24, %29
%33 = phi i32 [ %15, %14 ], [ %25, %24 ], [ 0, %26 ], [ 0, %29 ]
%34 = tail call i32 @exit(i32 %33)
unreachable
}