#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 */
struct commandData {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ toDasaDemo(char *, int);
void power(struct commandData *words, int arg) {
  printf("in power function: arg = %d \n", arg);
  if (arg == 1) {
    printf("TURNING ON\n");
    toDasaDemo("ON", -1);
  } else if (arg == 0) {
    printf("TURNING OFF\n");
    toDasaDemo("OFF", -1);
  }
}


x86 assembly (clang, -O0):
<power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    116e <power+0x4e>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0xffffffff,%esi
call   1040 <toDasaDemo@plt>
jmp    119c <power+0x7c>
cmpl   $0x0,-0xc(%rbp)
jne    1197 <power+0x77>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0xffffffff,%esi
call   1040 <toDasaDemo@plt>
jmp    119c <power+0x7c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<power>:
push   %rbx
mov    %esi,%ebx
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
je     115a <power+0x2a>
test   %ebx,%ebx
jne    117b <power+0x4b>
lea    0xed5(%rip),%rbx
lea    0xec6(%rip),%rdi
jmp    1168 <power+0x38>
lea    0xed1(%rip),%rbx
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
pop    %rbx
jmp    1050 <toDasaDemo@plt>
pop    %rbx
ret

LLVM IR (-O0):
%struct.commandData = type { i32 }
@.str = [30 x i8] c"in power function: arg = %d \0A\00"
@.str.1 = [12 x i8] c"TURNING ON\0A\00"
@.str.2 = [3 x i8] c"ON\00"
@.str.3 = [13 x i8] c"TURNING OFF\0A\00"
@.str.4 = [4 x i8] c"OFF\00"
define void @power(%struct.commandData* %0, i32 %1) {
%3 = alloca %struct.commandData*
%4 = alloca i32
store %struct.commandData* %0, %struct.commandData** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @toDasaDemo(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 -1)
br label %19
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @toDasaDemo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 -1)
br label %18
18: ; preds = %15, %12
br label %19
19: ; preds = %18, %9
ret void
}

LLVM IR (-O2):
%struct.commandData = type { i32 }
@.str = [30 x i8] c"in power function: arg = %d \0A\00"
@.str.2 = [3 x i8] c"ON\00"
@.str.4 = [4 x i8] c"OFF\00"
@str = [12 x i8] c"TURNING OFF\00"
@str.5 = [11 x i8] c"TURNING ON\00"
define void @power(%struct.commandData* nocapture readnone %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %1)
switch i32 %1, label %10 [
i32 1, label %5
i32 0, label %4
]
4: ; preds = %2
br label %5
5: ; preds = %2, %4
%6 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0), %2 ]
%7 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %4 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %2 ]
%8 = tail call i32 @puts(i8* dereferenceable(1) %6)
%9 = tail call i32 @toDasaDemo(i8* %7, i32 -1)
br label %10
10: ; preds = %5, %2
ret void
}