#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ input;

/* Variables and functions */
scalar_t__ isascii(int);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ usbtiny_spi(int *, int *);
int /*<<< orphan*/ usleep(int);
void do_printf_ui(void) {
  uint8_t cont = 1;
  while (cont) {
    uint8_t input[4] = {0, 0, 0, 0};
    uint8_t output[4];
    usbtiny_spi(input, output);
    for (uint8_t i = 0; i < sizeof(input); i++) {
      if (output[i] && isascii(output[i]))
        putchar(output[i]);
    }
    usleep(1000);
  }
  return;
}


x86 assembly (clang, -O0):
<do_printf_ui>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11f0 <do_printf_ui+0xa0>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <usbtiny_spi@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    $0x10,%rax
jae    11e1 <do_printf_ui+0x91>
movslq -0x34(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
je     11ce <do_printf_ui+0x7e>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
call   1060 <isascii@plt>
cmp    $0x0,%rax
je     11ce <do_printf_ui+0x7e>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
call   1030 <putchar@plt>
jmp    11d3 <do_printf_ui+0x83>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118d <do_printf_ui+0x3d>
mov    $0x3e8,%edi
call   1070 <usleep@plt>
jmp    115f <do_printf_ui+0xf>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_printf_ui>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0x10(%rsp),%r14
mov    %rsp,%r15
jmp    116a <do_printf_ui+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x3e8,%edi
call   1060 <usleep@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <usbtiny_spi@plt>
xor    %ebx,%ebx
jmp    119a <do_printf_ui+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x10,%rbx
je     1160 <do_printf_ui+0x20>
mov    (%rsp,%rbx,4),%edi
test   %edi,%edi
je     1190 <do_printf_ui+0x50>
call   1050 <isascii@plt>
test   %rax,%rax
je     1190 <do_printf_ui+0x50>
mov    (%rsp,%rbx,4),%edi
call   1030 <putchar@plt>
jmp    1190 <do_printf_ui+0x50>

LLVM IR (-O0):
define void @do_printf_ui() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca [4 x i32]
%4 = alloca i32
store i32 1, i32* %1
br label %5
5: ; preds = %40, %0
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %42
8: ; preds = %5
%9 = bitcast [4 x i32]* %2 to i8*
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%12 = call i32 @usbtiny_spi(i32* %10, i32* %11)
store i32 0, i32* %4
br label %13
13: ; preds = %37, %8
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %15, 16
br i1 %16, label %17, label %40
17: ; preds = %13
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %36
23: ; preds = %17
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i64 @isascii(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %23
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 @putchar(i32 %34)
br label %36
36: ; preds = %30, %23, %17
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %13
40: ; preds = %13
%41 = call i32 @usleep(i32 1000)
br label %5
42: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @do_printf_ui() {
%1 = alloca [4 x i32]
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [4 x i32]* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
br label %7
7: ; preds = %9, %0
%8 = call i32 @usbtiny_spi(i32* %5, i32* %6)
br label %11
9: ; preds = %22
%10 = call i32 @usleep(i32 1000)
br label %7
11: ; preds = %7, %22
%12 = phi i64 [ 0, %7 ], [ %23, %22 ]
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %11
%17 = call i64 @isascii(i32 %14)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %13
%21 = call i32 @putchar(i32 %20)
br label %22
22: ; preds = %11, %16, %19
%23 = add nuw nsw i64 %12, 1
%24 = icmp eq i64 %23, 16
br i1 %24, label %9, label %11
}