#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 rbs_done();
int rbs_init(int /*<<< orphan*/);
int /*<<< orphan*/ rbs_tick(unsigned char *, unsigned char *, unsigned char *,
                            unsigned char *, unsigned char);
int main() {
  unsigned char jtag_TCK, jtag_TMS, jtag_TDI, jtag_TRSTn;
  unsigned char jtag_TDO = 0;
  printf("calling rbs_init\n");
  int v = rbs_init(0);
  printf("tick 1\n");
  rbs_tick(&jtag_TCK, &jtag_TMS, &jtag_TDI, &jtag_TRSTn, jtag_TDO);
  printf("jtag exit is %d\n", rbs_done());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x9(%rbp)
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1040 <rbs_init@plt>
mov    %eax,-0x10(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x5(%rbp),%rdi
lea    -0x6(%rbp),%rsi
lea    -0x7(%rbp),%rdx
lea    -0x8(%rbp),%rcx
movzbl -0x9(%rbp),%r8d
call   1060 <rbs_tick@plt>
mov    $0x0,%al
call   1030 <rbs_done@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb9(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1040 <rbs_init@plt>
lea    0xeb7(%rip),%rdi
call   1050 <puts@plt>
lea    0x7(%rsp),%rdi
lea    0x6(%rsp),%rsi
lea    0x5(%rsp),%rdx
lea    0x4(%rsp),%rcx
xor    %r8d,%r8d
call   1070 <rbs_tick@plt>
xor    %eax,%eax
call   1030 <rbs_done@plt>
lea    0xe66(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"calling rbs_init\0A\00"
@.str.1 = [8 x i8] c"tick 1\0A\00"
@.str.2 = [17 x i8] c"jtag exit is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i32
store i32 0, i32* %1
store i8 0, i8* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @rbs_init(i32 0)
store i32 %9, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8, i8* %6
%12 = call i32 @rbs_tick(i8* %2, i8* %3, i8* %4, i8* %5, i8 zeroext %11)
%13 = call i32 (...) @rbs_done()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [17 x i8] c"jtag exit is %d\0A\00"
@str = [17 x i8] c"calling rbs_init\00"
@str.3 = [7 x i8] c"tick 1\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @rbs_init(i32 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.3, i64 0, i64 0))
%8 = call i32 @rbs_tick(i8* %1, i8* %2, i8* %3, i8* %4, i8 zeroext 0)
%9 = call i32 (...) @rbs_done()
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %9)
ret i32 0
}