#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 comm_write(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ ucconnect();
int ucprot(int);
int ucgo(unsigned long addr) {
  int retval;
  char obuf[32];
  char ibuf[32];
  if (addr & 0x3)
    return 0;
  if ((ucprot(-1) == 1) && (!ucconnect())) {
    fprintf(stderr, "Can not connect!\n");
    return (0x10 + 0x04);
  }
  sprintf(obuf, "G%08lX#", addr);
  retval = comm_write(obuf, strlen(obuf));
  return retval;
}


x86 assembly (clang, -O0):
<ucgo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
je     118a <ucgo+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    1207 <ucgo+0xa7>
mov    $0xffffffff,%edi
call   1030 <ucprot@plt>
cmp    $0x1,%eax
jne    11ce <ucgo+0x6e>
mov    $0x0,%al
call   1080 <ucconnect@plt>
cmp    $0x0,%eax
jne    11ce <ucgo+0x6e>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x14,-0x4(%rbp)
jmp    1207 <ucgo+0xa7>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe35(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
call   1040 <comm_write@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ucgo>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
test   $0x3,%bl
jne    11ce <ucgo+0x6e>
mov    $0xffffffff,%edi
call   1030 <ucprot@plt>
cmp    $0x1,%eax
jne    118b <ucgo+0x2b>
xor    %eax,%eax
call   1080 <ucconnect@plt>
test   %eax,%eax
je     11b4 <ucgo+0x54>
lea    0xe80(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <comm_write@plt>
jmp    11ce <ucgo+0x6e>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x14,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"Can not connect!\0A\00"
@.str.1 = [8 x i8] c"G%08lX#\00"
define i32 @ucgo(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
store i64 %0, i64* %3
%7 = load i64, i64* %3
%8 = and i64 %7, 3
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %29
11: ; preds = %1
%12 = call i32 @ucprot(i32 -1)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = call i32 (...) @ucconnect()
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 20, i32* %2
br label %29
20: ; preds = %14, %11
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%22 = load i64, i64* %3
%23 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %22)
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = call i32 @comm_write(i8* %24, i32 %26)
store i32 %27, i32* %4
%28 = load i32, i32* %4
store i32 %28, i32* %2
br label %29
29: ; preds = %20, %17, %10
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Can not connect!\0A\00"
@.str.1 = [8 x i8] c"G%08lX#\00"
define i32 @ucgo(i64 %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = and i64 %0, 3
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = tail call i32 @ucprot(i32 -1)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = tail call i32 (...) @ucconnect()
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %19
15: ; preds = %9, %6
%16 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %0)
%17 = call i32 @strlen(i8* %3)
%18 = call i32 @comm_write(i8* %3, i32 %17)
br label %19
19: ; preds = %1, %15, %12
%20 = phi i32 [ %18, %15 ], [ 20, %12 ], [ 0, %1 ]
ret i32 %20
}