#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*/ newline();
int /*<<< orphan*/ print_word(unsigned int);
int /*<<< orphan*/ puts(char *);
int scan_hexnum(unsigned int *);
void write_ioreg() {
  unsigned int *p;
  unsigned int v;
  if (scan_hexnum((unsigned *)&p) == 0x0) {
    if (scan_hexnum(&v) == 0x0) {
      *p = v;
      puts("Written ");
      print_word(v);
      puts(" at ");
      print_word((unsigned)p);
      newline();
      return;
    }
  }
  puts("Invalid arguments\n");
}


x86 assembly (clang, -O0):
<write_ioreg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1060 <scan_hexnum@plt>
cmp    $0x0,%eax
jne    11b1 <write_ioreg+0x71>
lea    -0xc(%rbp),%rdi
call   1060 <scan_hexnum@plt>
cmp    $0x0,%eax
jne    11ac <write_ioreg+0x6c>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
mov    -0xc(%rbp),%edi
call   1050 <print_word@plt>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%edi
call   1050 <print_word@plt>
mov    $0x0,%al
call   1030 <newline@plt>
jmp    11bd <write_ioreg+0x7d>
jmp    11b1 <write_ioreg+0x71>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_ioreg>:
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
call   1060 <scan_hexnum@plt>
test   %eax,%eax
jne    1160 <write_ioreg+0x20>
lea    0xc(%rsp),%rdi
call   1060 <scan_hexnum@plt>
test   %eax,%eax
je     1171 <write_ioreg+0x31>
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
add    $0x18,%rsp
ret
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx)
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edi
call   1050 <print_word@plt>
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%edi
call   1050 <print_word@plt>
xor    %eax,%eax
call   1030 <newline@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Written \00"
@.str.1 = [5 x i8] c" at \00"
@.str.2 = [19 x i8] c"Invalid arguments\0A\00"
define void @write_ioreg() {
%1 = alloca i32*
%2 = alloca i32
%3 = bitcast i32** %1 to i32*
%4 = call i32 @scan_hexnum(i32* %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %0
%7 = call i32 @scan_hexnum(i32* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32*, i32** %1
store i32 %10, i32* %11
%12 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %2
%14 = call i32 @print_word(i32 %13)
%15 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32*, i32** %1
%17 = ptrtoint i32* %16 to i32
%18 = call i32 @print_word(i32 %17)
%19 = call i32 (...) @newline()
br label %23
20: ; preds = %6
br label %21
21: ; preds = %20, %0
%22 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %9
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Written \00"
@.str.1 = [5 x i8] c" at \00"
@.str.2 = [19 x i8] c"Invalid arguments\0A\00"
define void @write_ioreg() {
%1 = alloca i32*
%2 = alloca i32
%3 = bitcast i32** %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32** %1 to i32*
%6 = call i32 @scan_hexnum(i32* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %0
%9 = call i32 @scan_hexnum(i32* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32*, i32** %1
store i32 %12, i32* %13
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = call i32 @print_word(i32 %15)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32*, i32** %1
%19 = ptrtoint i32* %18 to i64
%20 = trunc i64 %19 to i32
%21 = call i32 @print_word(i32 %20)
%22 = call i32 (...) @newline()
br label %25
23: ; preds = %8, %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %11
ret void
}