#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*/ atoi(char *);
int i8k_get_fan_status(int);
int i8k_set_fan(int, int /*<<< orphan*/);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, int, int);
int fan(int argc, char **argv) {
  int left, right;
  if ((argc > 1) && isdigit(argv[1][0])) {
    left = i8k_set_fan(1, atoi(argv[1]));
  } else {
    left = i8k_get_fan_status(1);
  }
  if ((argc > 2) && isdigit(argv[2][0])) {
    right = i8k_set_fan(0, atoi(argv[2]));
  } else {
    right = i8k_get_fan_status(0);
  }
  printf("%d %d\n", left, right);
  return 0;
}


x86 assembly (clang, -O0):
<fan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    11a4 <fan+0x54>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11a4 <fan+0x54>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%esi
mov    $0x1,%edi
call   1050 <i8k_set_fan@plt>
mov    %eax,-0x14(%rbp)
jmp    11b1 <fan+0x61>
mov    $0x1,%edi
call   1040 <i8k_get_fan_status@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x4(%rbp)
jle    11f3 <fan+0xa3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11f3 <fan+0xa3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1050 <i8k_set_fan@plt>
mov    %eax,-0x18(%rbp)
jmp    11fd <fan+0xad>
xor    %edi,%edi
call   1040 <i8k_get_fan_status@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xdf6(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fan>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x2,%edi
jl     1186 <fan+0x36>
mov    0x8(%rbx),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1186 <fan+0x36>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    $0x1,%edi
mov    %eax,%esi
call   1050 <i8k_set_fan@plt>
jmp    1190 <fan+0x40>
mov    $0x1,%edi
call   1040 <i8k_get_fan_status@plt>
mov    %eax,%r14d
cmp    $0x3,%ebp
jl     11bd <fan+0x6d>
mov    0x10(%rbx),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11bd <fan+0x6d>
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1050 <i8k_set_fan@plt>
jmp    11c4 <fan+0x74>
xor    %edi,%edi
call   1040 <i8k_get_fan_status@plt>
lea    0xe35(%rip),%rdi
mov    %r14d,%esi
mov    %eax,%edx
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\00"
define i32 @fan(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %23
9: ; preds = %2
%10 = load i8**, i8*** %4
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = call i64 @isdigit(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %9
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
%22 = call i32 @i8k_set_fan(i32 1, i32 %21)
store i32 %22, i32* %5
br label %25
23: ; preds = %9, %2
%24 = call i32 @i8k_get_fan_status(i32 1)
store i32 %24, i32* %5
br label %25
25: ; preds = %23, %17
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, 2
br i1 %27, label %28, label %42
28: ; preds = %25
%29 = load i8**, i8*** %4
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = call i64 @isdigit(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %28
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
%41 = call i32 @i8k_set_fan(i32 0, i32 %40)
store i32 %41, i32* %6
br label %44
42: ; preds = %28, %25
%43 = call i32 @i8k_get_fan_status(i32 0)
store i32 %43, i32* %6
br label %44
44: ; preds = %42, %36
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %45, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
define i32 @fan(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = tail call i64 @isdigit(i8 signext %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = load i8*, i8** %5
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32 @i8k_set_fan(i32 1, i32 %12)
br label %16
14: ; preds = %4, %2
%15 = tail call i32 @i8k_get_fan_status(i32 1)
br label %16
16: ; preds = %14, %10
%17 = phi i32 [ %13, %10 ], [ %15, %14 ]
%18 = icmp sgt i32 %0, 2
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = load i8, i8* %21
%23 = tail call i64 @isdigit(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %19
%26 = load i8*, i8** %20
%27 = tail call i32 @atoi(i8* %26)
%28 = tail call i32 @i8k_set_fan(i32 0, i32 %27)
br label %31
29: ; preds = %19, %16
%30 = tail call i32 @i8k_get_fan_status(i32 0)
br label %31
31: ; preds = %29, %25
%32 = phi i32 [ %28, %25 ], [ %30, %29 ]
%33 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %32)
ret i32 0
}