#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 error(char *);
int /*<<< orphan*/ lprintf(char *, char *, unsigned int);
scalar_t__ parse_address(char *, unsigned int *);
int si_tr(int argc, char *argv[]) {
  unsigned int address;
  if (argc < 2)
    return error("address missing");
  if (parse_address(argv[1], &address) != 0)
    return error("invalid address syntax (see 'help tr')");
  lprintf("logical address %s => physical %05lX\n", argv[1], address);
  return (0);
}


x86 assembly (clang, -O0):
<si_tr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115d <si_tr+0x2d>
lea    0xeb0(%rip),%rdi
call   1030 <error@plt>
mov    %eax,-0x4(%rbp)
jmp    11aa <si_tr+0x7a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <parse_address@plt>
cmp    $0x0,%rax
je     118c <si_tr+0x5c>
lea    0xe91(%rip),%rdi
call   1030 <error@plt>
mov    %eax,-0x4(%rbp)
jmp    11aa <si_tr+0x7a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
lea    0xe99(%rip),%rdi
call   1040 <lprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<si_tr>:
cmp    $0x1,%edi
jg     1141 <si_tr+0x11>
lea    0xec4(%rip),%rdi
jmp    1030 <error@plt>
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xc(%rsp),%rsi
call   1050 <parse_address@plt>
test   %rax,%rax
je     116a <si_tr+0x3a>
lea    0xead(%rip),%rdi
call   1030 <error@plt>
jmp    1180 <si_tr+0x50>
mov    0x8(%rbx),%rsi
mov    0xc(%rsp),%edx
lea    0xebe(%rip),%rdi
call   1040 <lprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"address missing\00"
@.str.1 = [39 x i8] c"invalid address syntax (see 'help tr')\00"
@.str.2 = [38 x i8] c"logical address %s => physical %05lX\0A\00"
define i32 @si_tr(i32 %0, i8** %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 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %3
br label %25
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @parse_address(i8* %14, i32* %6)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %3
br label %25
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i32, i32* %6
%24 = call i32 @lprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %23)
store i32 0, i32* %3
br label %25
25: ; preds = %19, %17, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [16 x i8] c"address missing\00"
@.str.1 = [39 x i8] c"invalid address syntax (see 'help tr')\00"
@.str.2 = [38 x i8] c"logical address %s => physical %05lX\0A\00"
define i32 @si_tr(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %19
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i64 @parse_address(i8* %10, i32* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 @error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %19
15: ; preds = %8
%16 = load i8*, i8** %9
%17 = load i32, i32* %3
%18 = call i32 @lprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %17)
br label %19
19: ; preds = %15, %13, %6
%20 = phi i32 [ %7, %6 ], [ %14, %13 ], [ 0, %15 ]
ret i32 %20
}