#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*/ dasm_instruction(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strncmp(char *, char *, int);
int check_disasm(char *buf) {
  if (1024 > 7 && !strncmp(buf, "disasm", 6)) {
    int mem;
    if (sscanf(buf + 7, "%x", &mem) == 1 && mem >= 0 && mem <= 0xFFFF) {
      dasm_instruction(mem, stdout);
      printf("\n");
      return 1;
    } else {
      printf("usage: disasm [address]"
             "(where address is between 0x0000 and 0xFFFF inclusive)\n");
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_disasm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11e3 <check_disasm+0xa3>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
lea    0xe8e(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11cb <check_disasm+0x8b>
cmpl   $0x0,-0x14(%rbp)
jl     11cb <check_disasm+0x8b>
cmpl   $0xffff,-0x14(%rbp)
jg     11cb <check_disasm+0x8b>
mov    -0x14(%rbp),%edi
mov    0x2e34(%rip),%rax
mov    (%rax),%esi
call   1040 <dasm_instruction@plt>
lea    0xe9d(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ea <check_disasm+0xaa>
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <check_disasm+0xaa>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_disasm>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xea1(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    11cb <check_disasm+0x7b>
add    $0x7,%rbx
lea    0xe8b(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    11bd <check_disasm+0x6d>
mov    0xc(%rsp),%edi
test   %edi,%edi
js     11bd <check_disasm+0x6d>
cmp    $0xffff,%edi
jg     11bd <check_disasm+0x6d>
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
call   1060 <dasm_instruction@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
jmp    11cb <check_disasm+0x7b>
lea    0xe46(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"disasm\00"
@.str.1 = [3 x i8] c"%x\00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [79 x i8] c"usage: disasm [address](where address is between 0x0000 and 0xFFFF inclusive)\0A\00"
define i32 @check_disasm(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%7 = icmp ne i32 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 7
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %24
13: ; preds = %8
%14 = load i32, i32* %4
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp sle i32 %17, 65535
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* %4
%21 = load i32, i32* @stdout
%22 = call i32 @dasm_instruction(i32 %20, i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %27
24: ; preds = %16, %13, %8
%25 = call i32 @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %27
26: ; preds = %1
store i32 0, i32* %2
br label %27
27: ; preds = %26, %24, %19
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [7 x i8] c"disasm\00"
@.str.1 = [3 x i8] c"%x\00"
@stdout = global i32 0
@str = [78 x i8] c"usage: disasm [address](where address is between 0x0000 and 0xFFFF inclusive)\00"
define i32 @check_disasm(i8* %0) {
%2 = alloca i32
%3 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %23
5: ; preds = %1
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds i8, i8* %0, i64 7
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = icmp eq i32 %8, 1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, -1
%12 = select i1 %9, i1 %11, i1 false
%13 = icmp slt i32 %10, 65536
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %15, label %19
15: ; preds = %5
%16 = load i32, i32* @stdout
%17 = call i32 @dasm_instruction(i32 %10, i32 %16)
%18 = call i32 @putchar(i32 10)
br label %21
19: ; preds = %5
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
%22 = phi i32 [ 1, %15 ], [ 0, %19 ]
br label %23
23: ; preds = %1, %21
%24 = phi i32 [ %22, %21 ], [ 0, %1 ]
ret i32 %24
}