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


x86 assembly (clang, -O0):
<testWriteInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x5(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x5(%rbp),%rdi
mov    $0xffffffd6,%esi
call   1060 <fiolSWriteInt@plt>
lea    -0x5(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11af <testWriteInt+0x6f>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c8 <testWriteInt+0x88>
lea    -0x5(%rbp),%rsi
lea    0xe78(%rip),%rdi
lea    0xe61(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x5(%rbp),%rdi
mov    $0x34e,%esi
call   1060 <fiolSWriteInt@plt>
lea    -0x5(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <testWriteInt+0xd1>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122a <testWriteInt+0xea>
lea    -0x5(%rbp),%rsi
lea    0xe16(%rip),%rdi
lea    0xe41(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testWriteInt>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xffffffd6,%esi
call   1060 <fiolSWriteInt@plt>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ac <testWriteInt+0x6c>
lea    0xe6d(%rip),%rdi
lea    0xe62(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b8 <testWriteInt+0x78>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x34e,%esi
call   1060 <fiolSWriteInt@plt>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1206 <testWriteInt+0xc6>
lea    0xe13(%rip),%rdi
lea    0xe36(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1212 <testWriteInt+0xd2>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Testing fiolSWriteInt...\0D\0A\00"
@.str.1 = [7 x i8] c"\09-42\0D\0A\00"
@.str.2 = [4 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 = [8 x i8] c"\09+846\0D\0A\00"
@.str.6 = [4 x i8] c"846\00"
define void @testWriteInt() {
%1 = alloca [5 x i8]
%2 = bitcast [5 x i8]* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 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 @fiolSWriteInt(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 ([4 x i8], [4 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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %12, %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%18 = call i32 @fiolSWriteInt(i8* %17, i32 846)
%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 = [4 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"846\00"
@str = [26 x i8] c"Testing fiolSWriteInt...\0D\00"
@str.7 = [6 x i8] c"\09-42\0D\00"
@str.8 = [7 x i8] c"\09+846\0D\00"
@str.10 = [11 x i8] c"\09\09Passed!\0D\00"
define void @testWriteInt() {
%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 ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
%5 = call i32 @fiolSWriteInt(i8* %2, i32 -42)
%6 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.8, i64 0, i64 0))
%14 = call i32 @fiolSWriteInt(i8* %2, i32 846)
%15 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
br label %21
19: ; preds = %12
%20 = 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 %21
21: ; preds = %19, %17
ret void
}