#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 atoi(char *);
scalar_t__ ioctl(int /*<<< orphan*/, int, int);
int main(int argc, char *argv[]) {
  if (argc != 2)
    return 1;
  int n = atoi(argv[1]);
  if (ioctl(0, (0x5606), n) < 0)
    return 1;
  if (ioctl(0, (0x5607), n) < 0)
    return 1;
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     114c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11ad <main+0x8d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edx
xor    %edi,%edi
mov    $0x5606,%esi
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    1181 <main+0x61>
movl   $0x1,-0x4(%rbp)
jmp    11ad <main+0x8d>
mov    -0x14(%rbp),%edx
xor    %edi,%edi
mov    $0x5607,%esi
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    11a6 <main+0x86>
movl   $0x1,-0x4(%rbp)
jmp    11ad <main+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x2,%edi
jne    1160 <main+0x40>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    $0x5606,%esi
mov    %eax,%edx
call   1030 <ioctl@plt>
test   %rax,%rax
js     1160 <main+0x40>
xor    %edi,%edi
mov    $0x5607,%esi
mov    %ebp,%edx
call   1030 <ioctl@plt>
mov    %rax,%rbx
shr    $0x3f,%rbx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
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
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %25
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i64 @ioctl(i32 0, i32 22022, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %10
store i32 1, i32* %3
br label %25
19: ; preds = %10
%20 = load i32, i32* %6
%21 = call i64 @ioctl(i32 0, i32 22023, i32 %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %3
br label %25
24: ; preds = %19
store i32 0, i32* %3
br label %25
25: ; preds = %24, %23, %18, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = tail call i64 @ioctl(i32 0, i32 22022, i32 %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = tail call i64 @ioctl(i32 0, i32 22023, i32 %7)
%12 = lshr i64 %11, 63
%13 = trunc i64 %12 to i32
br label %14
14: ; preds = %4, %10, %2
%15 = phi i32 [ 1, %2 ], [ 1, %4 ], [ %13, %10 ]
ret i32 %15
}