#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ progress(double);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
char *utoa32_sse(int);
char *utoa32_sse_2(int);
char *utoa64_sse(int);
void verify32() {
  char expected[32];
  char *result;
  for (uint32_t x = 0; x <= 99999999; x++) {
    sprintf(expected, "%u", x);
    if (x % 10000 == 0) {
      progress(x / 99999999.0);
    }
    result = utoa32_sse(x);
    if (strcmp(expected, result) != 0) {
      printf("utoa32_sse failed, expected = '%s', result = '%s'\n", expected,
             result);
      exit(1);
    }
    result = utoa32_sse_2(x);
    if (strcmp(expected, result) != 0) {
      printf("utoa32_sse_2 failed, expected = '%s', result = '%s'\n", expected,
             result);
      exit(1);
    }
    result = utoa64_sse(x);
    if (strcmp(expected, result) != 0) {
      printf("utoa64_sse failed, expected = '%s', result = '%s'\n", expected,
             result);
      exit(1);
    }
  }
  progress(1.0);
  putchar('\n');
}


x86 assembly (clang, -O0):
<verify32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5f5e0ff,-0x2c(%rbp)
jg     12bf <verify32+0x12f>
lea    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xe56(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e9 <verify32+0x59>
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xe28(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <progress@plt>
mov    -0x2c(%rbp),%edi
call   1060 <utoa32_sse@plt>
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     122a <verify32+0x9a>
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdf8(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x2c(%rbp),%edi
call   1030 <utoa32_sse_2@plt>
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     126b <verify32+0xdb>
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdea(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x2c(%rbp),%edi
call   1090 <utoa64_sse@plt>
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12ac <verify32+0x11c>
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdde(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    12b1 <verify32+0x121>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119f <verify32+0xf>
movsd  0xd39(%rip),%xmm0
call   1050 <progress@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %ebx,%ebx
mov    $0xd1b71759,%r13d
lea    0xe63(%rip),%r14
mov    %rsp,%r15
mov    %ebx,%eax
imul   %r13,%rax
shr    $0x2d,%rax
imul   $0x2710,%eax,%ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   10a0 <sprintf@plt>
cmp    %ebx,%ebp
jne    11e5 <verify32+0x55>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  0xe20(%rip),%xmm0
call   1050 <progress@plt>
mov    %ebx,%edi
call   1060 <utoa32_sse@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rax,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1268 <verify32+0xd8>
mov    %ebx,%edi
call   1030 <utoa32_sse_2@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rax,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1271 <verify32+0xe1>
mov    %ebx,%edi
call   1090 <utoa64_sse@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rax,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    127a <verify32+0xea>
add    $0x1,%ebx
cmp    $0x5f5e100,%ebx
jne    11b0 <verify32+0x20>
movsd  0xdbe(%rip),%xmm0
call   1050 <progress@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda4(%rip),%rdi
jmp    1281 <verify32+0xf1>
lea    0xdce(%rip),%rdi
jmp    1281 <verify32+0xf1>
lea    0xdfa(%rip),%rdi
mov    %rsp,%rsi
mov    %r12,%rdx
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [51 x i8] c"utoa32_sse failed, expected = '%s', result = '%s'\0A\00"
@.str.2 = [53 x i8] c"utoa32_sse_2 failed, expected = '%s', result = '%s'\0A\00"
@.str.3 = [51 x i8] c"utoa64_sse failed, expected = '%s', result = '%s'\0A\00"
define void @verify32() {
%1 = alloca [32 x i8]
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %56, %0
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 99999999
br i1 %6, label %7, label %59
7: ; preds = %4
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %3
%12 = srem i32 %11, 10000
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %7
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 0x4197D783FC000000
%18 = call i32 @progress(double %17)
br label %19
19: ; preds = %14, %7
%20 = load i32, i32* %3
%21 = call i8* @utoa32_sse(i32 %20)
store i8* %21, i8** %2
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%23 = load i8*, i8** %2
%24 = call i64 @strcmp(i8* %22, i8* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%28 = load i8*, i8** %2
%29 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = load i32, i32* %3
%33 = call i8* @utoa32_sse_2(i32 %32)
store i8* %33, i8** %2
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%35 = load i8*, i8** %2
%36 = call i64 @strcmp(i8* %34, i8* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %31
%39 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%40 = load i8*, i8** %2
%41 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %31
%44 = load i32, i32* %3
%45 = call i8* @utoa64_sse(i32 %44)
store i8* %45, i8** %2
%46 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%47 = load i8*, i8** %2
%48 = call i64 @strcmp(i8* %46, i8* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %43
%51 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%52 = load i8*, i8** %2
%53 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %51, i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %43
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %4
59: ; preds = %4
%60 = call i32 @progress(double 1.000000e+00)
%61 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [51 x i8] c"utoa32_sse failed, expected = '%s', result = '%s'\0A\00"
@.str.2 = [53 x i8] c"utoa32_sse_2 failed, expected = '%s', result = '%s'\0A\00"
@.str.3 = [51 x i8] c"utoa64_sse failed, expected = '%s', result = '%s'\0A\00"
define void @verify32() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %9
3: ; preds = %32
%4 = add nuw nsw i32 %10, 1
%5 = icmp eq i32 %4, 100000000
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = call i32 @progress(double 1.000000e+00)
%8 = call i32 @putchar(i8 signext 10)
ret void
9: ; preds = %0, %3
%10 = phi i32 [ 0, %0 ], [ %4, %3 ]
%11 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = urem i32 %10, 10000
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = sitofp i32 %10 to double
%16 = fdiv double %15, 0x4197D783FC000000
%17 = call i32 @progress(double %16)
br label %18
18: ; preds = %14, %9
%19 = call i8* @utoa32_sse(i32 %10)
%20 = call i64 @strcmp(i8* %2, i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %19)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %18
%26 = call i8* @utoa32_sse_2(i32 %10)
%27 = call i64 @strcmp(i8* %2, i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %26)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %25
%33 = call i8* @utoa64_sse(i32 %10)
%34 = call i64 @strcmp(i8* %2, i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %3, label %36
36: ; preds = %32
%37 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %33)
%38 = call i32 @exit(i32 1)
unreachable
}