#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*/ printf(char *, int);
scalar_t__ putbyte(int, unsigned char);
int special_cmd(int fd, unsigned char cmd) {
  int i;
  if (putbyte(fd, 0xE6))
    for (i = 0; i < 4; i++) {
      printf("special_cmd %i\n", i);
      if ((!putbyte(fd, 0xE8)) || (!putbyte(fd, (cmd >> 6) & 0x3)))
        return 0;
      cmd <<= 2;
    }
  else
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<special_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%edi
mov    $0xe6,%esi
call   1040 <putbyte@plt>
cmp    $0x0,%rax
je     11c7 <special_cmd+0xa7>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11c2 <special_cmd+0xa2>
mov    -0x10(%rbp),%esi
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0xe8,%esi
call   1040 <putbyte@plt>
cmp    $0x0,%rax
je     119e <special_cmd+0x7e>
mov    -0x8(%rbp),%edi
movzbl -0x9(%rbp),%eax
sar    $0x6,%eax
and    $0x3,%eax
movzbl %al,%esi
call   1040 <putbyte@plt>
cmp    $0x0,%rax
jne    11aa <special_cmd+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    11da <special_cmd+0xba>
movzbl -0x9(%rbp),%eax
shl    $0x2,%eax
mov    %al,-0x9(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <special_cmd+0x2f>
jmp    11d3 <special_cmd+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    11da <special_cmd+0xba>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<special_cmd>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0xe6,%esi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122b <special_cmd+0x10b>
lea    0xebd(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
mov    $0xe8,%esi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122d <special_cmd+0x10d>
mov    %r14d,%eax
shr    $0x6,%al
movzbl %al,%esi
mov    %ebp,%edi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122d <special_cmd+0x10d>
lea    0xe7f(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
mov    $0xe8,%esi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122d <special_cmd+0x10d>
mov    %r14d,%eax
shr    $0x4,%al
and    $0x3,%al
movzbl %al,%esi
mov    %ebp,%edi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122d <special_cmd+0x10d>
lea    0xe42(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
mov    $0xe8,%esi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122d <special_cmd+0x10d>
mov    %r14d,%eax
shr    $0x2,%al
and    $0x3,%al
movzbl %al,%esi
mov    %ebp,%edi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122d <special_cmd+0x10d>
lea    0xe09(%rip),%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
mov    $0xe8,%esi
call   1040 <putbyte@plt>
test   %rax,%rax
je     122d <special_cmd+0x10d>
and    $0x3,%r14b
movzbl %r14b,%esi
mov    %ebp,%edi
call   1040 <putbyte@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
jmp    122d <special_cmd+0x10d>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"special_cmd %i\0A\00"
define i32 @special_cmd(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i32 %0, i32* %4
store i8 %1, i8* %5
%7 = load i32, i32* %4
%8 = call i64 @putbyte(i32 %7, i8 zeroext -26)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %39
10: ; preds = %2
store i32 0, i32* %6
br label %11
11: ; preds = %35, %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load i32, i32* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %4
%18 = call i64 @putbyte(i32 %17, i8 zeroext -24)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = load i32, i32* %4
%22 = load i8, i8* %5
%23 = zext i8 %22 to i32
%24 = ashr i32 %23, 6
%25 = and i32 %24, 3
%26 = trunc i32 %25 to i8
%27 = call i64 @putbyte(i32 %21, i8 zeroext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %20, %14
store i32 0, i32* %3
br label %41
30: ; preds = %20
%31 = load i8, i8* %5
%32 = zext i8 %31 to i32
%33 = shl i32 %32, 2
%34 = trunc i32 %33 to i8
store i8 %34, i8* %5
br label %35
35: ; preds = %30
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %11
38: ; preds = %11
br label %40
39: ; preds = %2
store i32 0, i32* %3
br label %41
40: ; preds = %38
store i32 1, i32* %3
br label %41
41: ; preds = %40, %39, %29
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [16 x i8] c"special_cmd %i\0A\00"
define i32 @special_cmd(i32 %0, i8 zeroext %1) {
%3 = tail call i64 @putbyte(i32 %0, i8 zeroext -26)
%4 = icmp eq i64 %3, 0
br i1 %4, label %40, label %5
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0)
%7 = tail call i64 @putbyte(i32 %0, i8 zeroext -24)
%8 = icmp eq i64 %7, 0
br i1 %8, label %40, label %9
9: ; preds = %5
%10 = lshr i8 %1, 6
%11 = tail call i64 @putbyte(i32 %0, i8 zeroext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %40, label %13
13: ; preds = %9
%14 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1)
%15 = tail call i64 @putbyte(i32 %0, i8 zeroext -24)
%16 = icmp eq i64 %15, 0
br i1 %16, label %40, label %17
17: ; preds = %13
%18 = lshr i8 %1, 4
%19 = and i8 %18, 3
%20 = tail call i64 @putbyte(i32 %0, i8 zeroext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %40, label %22
22: ; preds = %17
%23 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 2)
%24 = tail call i64 @putbyte(i32 %0, i8 zeroext -24)
%25 = icmp eq i64 %24, 0
br i1 %25, label %40, label %26
26: ; preds = %22
%27 = lshr i8 %1, 2
%28 = and i8 %27, 3
%29 = tail call i64 @putbyte(i32 %0, i8 zeroext %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %40, label %31
31: ; preds = %26
%32 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 3)
%33 = tail call i64 @putbyte(i32 %0, i8 zeroext -24)
%34 = icmp eq i64 %33, 0
br i1 %34, label %40, label %35
35: ; preds = %31
%36 = and i8 %1, 3
%37 = tail call i64 @putbyte(i32 %0, i8 zeroext %36)
%38 = icmp ne i64 %37, 0
%39 = zext i1 %38 to i32
br label %40
40: ; preds = %35, %5, %9, %13, %17, %22, %26, %31, %2
%41 = phi i32 [ 0, %2 ], [ 0, %9 ], [ 0, %5 ], [ 0, %13 ], [ 0, %17 ], [ 0, %22 ], [ 0, %26 ], [ 0, %31 ], [ %39, %35 ]
ret i32 %41
}