#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 EXIT_SUCCESS;
int atoi(char *);
int decimal_digits_naive(int const);
int decimal_digits_sse(int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int main(int argc, char *argv[]) {
  for (int i = 1; i < argc; i++) {
    const int x = atoi(argv[i]);
    if (x < 0) {
      printf("%15d: negative numbers not supported\n", x);
      continue;
    }
    const int ref = decimal_digits_naive(x);
    printf("%15d: digits %2d (correct)", x, ref);
    const int sse = decimal_digits_sse(x);
    printf(", %2d (SSE proc)", sse);
    if (sse != ref)
      printf(" FAILED");
    putchar('\n');
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121a <main+0xca>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11ad <main+0x5d>
mov    -0x18(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120c <main+0xbc>
mov    -0x18(%rbp),%edi
call   1060 <decimal_digits_naive@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <decimal_digits_sse@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1202 <main+0xb2>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x1d>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1202 <main+0xb2>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    $0x1,%r15d
lea    0xeca(%rip),%r12
jmp    1193 <main+0x43>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     1202 <main+0xb2>
mov    (%rbx,%r15,8),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11f0 <main+0xa0>
mov    %ebp,%edi
call   1060 <decimal_digits_naive@plt>
mov    %eax,%r13d
lea    0xe73(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
call   1050 <decimal_digits_sse@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13d,%ebp
je     1180 <main+0x30>
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x30>
nopl   0x0(%rax,%rax,1)
lea    0xe09(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118a <main+0x3a>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"%15d: negative numbers not supported\0A\00"
@.str.1 = [27 x i8] c"%15d: digits %2d (correct)\00"
@.str.2 = [17 x i8] c", %2d (SSE proc)\00"
@.str.3 = [8 x i8] c" FAILED\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %10
10: ; preds = %43, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %46
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %14
%24 = load i32, i32* %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %43
26: ; preds = %14
%27 = load i32, i32* %7
%28 = call i32 @decimal_digits_naive(i32 %27)
store i32 %28, i32* %8
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30)
%32 = load i32, i32* %7
%33 = call i32 @decimal_digits_sse(i32 %32)
store i32 %33, i32* %9
%34 = load i32, i32* %9
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %9
%37 = load i32, i32* %8
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %26
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %26
%42 = call i32 @putchar(i8 signext 10)
br label %43
43: ; preds = %41, %23
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %10
46: ; preds = %10
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
@.str = [38 x i8] c"%15d: negative numbers not supported\0A\00"
@.str.1 = [27 x i8] c"%15d: digits %2d (correct)\00"
@.str.2 = [17 x i8] c", %2d (SSE proc)\00"
@.str.3 = [8 x i8] c" FAILED\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %8
6: ; preds = %26, %2
%7 = load i32, i32* @EXIT_SUCCESS
ret i32 %7
8: ; preds = %4, %26
%9 = phi i64 [ 1, %4 ], [ %27, %26 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %26
16: ; preds = %8
%17 = tail call i32 @decimal_digits_naive(i32 %12)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %17)
%19 = tail call i32 @decimal_digits_sse(i32 %12)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = icmp eq i32 %19, %17
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
%25 = tail call i32 @putchar(i8 signext 10)
br label %26
26: ; preds = %24, %14
%27 = add nuw nsw i64 %9, 1
%28 = icmp eq i64 %27, %5
br i1 %28, label %6, label %8
}