#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*/ fiolSWriteUInt(char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void testWriteUInt() {
  char str[5] = {'\0', '\0', '\0', '\0', '\0'};
  printf("Testing fiolSWriteUInt...\r\n");
  printf("\t42\r\n");
  fiolSWriteUInt(str, 42);
  if (strcmp(str, "42") == 0)
    printf("\t\tPassed!\r\n");
  else
    printf("\t\tfailed, returned '%s' instead of '%s'\r\n", str, "42");
  printf("\t442\r\n");
  fiolSWriteUInt(&(str[1]), 42);
  if (strcmp(str, "442") == 0)
    printf("\t\tPassed!\r\n");
  else
    printf("\t\tfailed, returned '%s' instead of '%s'\r\n", str, "442");
}


x86 assembly (clang, -O0):
<testWriteUInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x5(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <memset@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x5(%rbp),%rdi
mov    $0x2a,%esi
call   1030 <fiolSWriteUInt@plt>
lea    -0x5(%rbp),%rdi
lea    0xed3(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11af <testWriteUInt+0x6f>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c8 <testWriteUInt+0x88>
lea    -0x5(%rbp),%rsi
lea    0xe74(%rip),%rdi
lea    0xe9f(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x5(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2a,%esi
call   1030 <fiolSWriteUInt@plt>
lea    -0x5(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1215 <testWriteUInt+0xd5>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122e <testWriteUInt+0xee>
lea    -0x5(%rbp),%rsi
lea    0xe0e(%rip),%rdi
lea    0xe38(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testWriteUInt>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2a,%esi
call   1040 <fiolSWriteUInt@plt>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11ac <testWriteUInt+0x6c>
lea    0xe69(%rip),%rdi
lea    0xe8d(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b8 <testWriteUInt+0x78>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
lea    0x9(%rsp),%rdi
mov    $0x2a,%esi
call   1040 <fiolSWriteUInt@plt>
lea    0xe50(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1205 <testWriteUInt+0xc5>
lea    0xe10(%rip),%rdi
lea    0xe33(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1211 <testWriteUInt+0xd1>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Testing fiolSWriteUInt...\0D\0A\00"
@.str.1 = [6 x i8] c"\0942\0D\0A\00"
@.str.2 = [3 x i8] c"42\00"
@.str.3 = [12 x i8] c"\09\09Passed!\0D\0A\00"
@.str.4 = [42 x i8] c"\09\09failed, returned '%s' instead of '%s'\0D\0A\00"
@.str.5 = [7 x i8] c"\09442\0D\0A\00"
@.str.6 = [4 x i8] c"442\00"
define void @testWriteUInt() {
%1 = alloca [5 x i8]
%2 = bitcast [5 x i8]* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%6 = call i32 @fiolSWriteUInt(i8* %5, i32 42)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %15
12: ; preds = %0
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %12, %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%18 = call i32 @fiolSWriteUInt(i8* %17, i32 42)
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %27
24: ; preds = %15
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %24, %22
ret void
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"42\00"
@.str.4 = [42 x i8] c"\09\09failed, returned '%s' instead of '%s'\0D\0A\00"
@.str.6 = [4 x i8] c"442\00"
@str = [27 x i8] c"Testing fiolSWriteUInt...\0D\00"
@str.7 = [5 x i8] c"\0942\0D\00"
@str.8 = [6 x i8] c"\09442\0D\00"
@str.10 = [11 x i8] c"\09\09Passed!\0D\00"
define void @testWriteUInt() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.7, i64 0, i64 0))
%5 = call i32 @fiolSWriteUInt(i8* %2, i32 42)
%6 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%15 = call i32 @fiolSWriteUInt(i8* %14, i32 42)
%16 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
br label %22
20: ; preds = %12
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
ret void
}