#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 */
scalar_t__ GPIOPinRead(int, int);
int /*<<< orphan*/ GPIOPinTypeGPIOInput(int, int);
int /*<<< orphan*/ GPIOPinTypeGPIOOutput(int, int);
int /*<<< orphan*/ GPIOPinWrite(int, int, int);
int /*<<< orphan*/ SysCtlPeripheralEnable(int);
void jtag_wait(void) {
  SysCtlPeripheralEnable(0x20000002);
  GPIOPinTypeGPIOOutput(0x40005000, 0x00000001);
  GPIOPinWrite(0x40005000, 0x00000001, 0xff);
  GPIOPinTypeGPIOInput(0x40005000, 0x00000001);
  if (GPIOPinRead(0x40005000, 0x00000001) == 0)
    for (;;)
      ;
  SysCtlPeripheralEnable(0x20000002);
}


x86 assembly (clang, -O0):
<jtag_wait>:
push   %rbp
mov    %rsp,%rbp
mov    $0x20000002,%edi
call   1030 <SysCtlPeripheralEnable@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
call   1060 <GPIOPinTypeGPIOOutput@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1070 <GPIOPinWrite@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
call   1040 <GPIOPinTypeGPIOInput@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
call   1050 <GPIOPinRead@plt>
cmp    $0x0,%rax
jne    11b3 <jtag_wait+0x63>
jmp    11ae <jtag_wait+0x5e>
jmp    11ae <jtag_wait+0x5e>
mov    $0x20000002,%edi
call   1030 <SysCtlPeripheralEnable@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<jtag_wait>:
push   %rax
mov    $0x20000002,%edi
call   1030 <SysCtlPeripheralEnable@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
call   1060 <GPIOPinTypeGPIOOutput@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1070 <GPIOPinWrite@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
call   1040 <GPIOPinTypeGPIOInput@plt>
mov    $0x40005000,%edi
mov    $0x1,%esi
call   1050 <GPIOPinRead@plt>
test   %rax,%rax
je     11b0 <jtag_wait+0x60>
mov    $0x20000002,%edi
pop    %rax
jmp    1030 <SysCtlPeripheralEnable@plt>
nopl   0x0(%rax)
jmp    11b0 <jtag_wait+0x60>

LLVM IR (-O0):
define void @jtag_wait() {
%1 = call i32 @SysCtlPeripheralEnable(i32 536870914)
%2 = call i32 @GPIOPinTypeGPIOOutput(i32 1073762304, i32 1)
%3 = call i32 @GPIOPinWrite(i32 1073762304, i32 1, i32 255)
%4 = call i32 @GPIOPinTypeGPIOInput(i32 1073762304, i32 1)
%5 = call i64 @GPIOPinRead(i32 1073762304, i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
br label %8
8: ; preds = %8, %7
br label %8
9: ; preds = %0
%10 = call i32 @SysCtlPeripheralEnable(i32 536870914)
ret void
}

LLVM IR (-O2):
define void @jtag_wait() {
%1 = tail call i32 @SysCtlPeripheralEnable(i32 536870914)
%2 = tail call i32 @GPIOPinTypeGPIOOutput(i32 1073762304, i32 1)
%3 = tail call i32 @GPIOPinWrite(i32 1073762304, i32 1, i32 255)
%4 = tail call i32 @GPIOPinTypeGPIOInput(i32 1073762304, i32 1)
%5 = tail call i64 @GPIOPinRead(i32 1073762304, i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0, %7
br label %7
8: ; preds = %0
%9 = tail call i32 @SysCtlPeripheralEnable(i32 536870914)
ret void
}