#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*/ fiolSWriteChar(char *, char);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void testWriteChar() {
  char str[5] = {'\0', '\0', '\0', '\0', '\0'};
  printf("Testing fiolSWriteChar...\r\n");
  printf("\tf, i, o, l\r\n");
  fiolSWriteChar(&(str[0]), 'f');
  fiolSWriteChar(&(str[1]), 'i');
  fiolSWriteChar(&(str[2]), 'o');
  fiolSWriteChar(&(str[3]), 'l');
  if (strcmp(str, "fiol") == 0)
    printf("\t\tPassed!\r\n");
  else
    printf("\t\tfailed, returned '%s' instead of '%s'\r\n", str, "fiol");
}


x86 assembly (clang, -O0):
<testWriteChar>:
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    $0x66,%esi
call   1030 <fiolSWriteChar@plt>
lea    -0x5(%rbp),%rdi
add    $0x1,%rdi
mov    $0x69,%esi
call   1030 <fiolSWriteChar@plt>
lea    -0x5(%rbp),%rdi
add    $0x2,%rdi
mov    $0x6f,%esi
call   1030 <fiolSWriteChar@plt>
lea    -0x5(%rbp),%rdi
add    $0x3,%rdi
mov    $0x6c,%esi
call   1030 <fiolSWriteChar@plt>
lea    -0x5(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e5 <testWriteChar+0xa5>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fe <testWriteChar+0xbe>
lea    -0x5(%rbp),%rsi
lea    0xe4b(%rip),%rdi
lea    0xe33(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testWriteChar>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
lea    0xee5(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x66,%esi
call   1030 <fiolSWriteChar@plt>
lea    0x9(%rsp),%rdi
mov    $0x69,%esi
call   1030 <fiolSWriteChar@plt>
lea    0xa(%rsp),%rdi
mov    $0x6f,%esi
call   1030 <fiolSWriteChar@plt>
lea    0xb(%rsp),%rdi
mov    $0x6c,%esi
call   1030 <fiolSWriteChar@plt>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11d9 <testWriteChar+0x99>
lea    0xe41(%rip),%rdi
lea    0xe35(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e5 <testWriteChar+0xa5>
lea    0xe77(%rip),%rdi
call   1040 <puts@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Testing fiolSWriteChar...\0D\0A\00"
@.str.1 = [14 x i8] c"\09f, i, o, l\0D\0A\00"
@.str.2 = [5 x i8] c"fiol\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"
define void @testWriteChar() {
%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 ([14 x i8], [14 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 @fiolSWriteChar(i8* %5, i8 signext 102)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%8 = call i32 @fiolSWriteChar(i8* %7, i8 signext 105)
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
%10 = call i32 @fiolSWriteChar(i8* %9, i8 signext 111)
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
%12 = call i32 @fiolSWriteChar(i8* %11, i8 signext 108)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %21
18: ; preds = %0
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %18, %16
ret void
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"fiol\00"
@.str.4 = [42 x i8] c"\09\09failed, returned '%s' instead of '%s'\0D\0A\00"
@str = [27 x i8] c"Testing fiolSWriteChar...\0D\00"
@str.5 = [13 x i8] c"\09f, i, o, l\0D\00"
@str.6 = [11 x i8] c"\09\09Passed!\0D\00"
define void @testWriteChar() {
%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 ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
%5 = call i32 @fiolSWriteChar(i8* %2, i8 signext 102)
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%7 = call i32 @fiolSWriteChar(i8* %6, i8 signext 105)
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
%9 = call i32 @fiolSWriteChar(i8* %8, i8 signext 111)
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
%11 = call i32 @fiolSWriteChar(i8* %10, i8 signext 108)
%12 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
br label %18
16: ; preds = %0
%17 = 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 ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
ret void
}