#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*/ assert(int);
int /*<<< orphan*/ integer_to_quantity(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int test_integer_to_quantity() {
  char qty[20];
  char value[20];
  int i;
  printf("test_integer_to_quantity...");
  sprintf(value, "%s", "1295");
  for (i = 0; i < 8 - 2; i++) {
    value[4 + i] = '0';
  }
  value[4 + i] = 0;
  integer_to_quantity(value, qty);
  assert(qty[0] == '1');
  assert(qty[1] == '2');
  assert(qty[2] == '.');
  assert(qty[3] == '9');
  assert(qty[4] == '5');
  for (i = 5; i < 5 + 8 - 2; i++) {
    assert(qty[i] == '0');
  }
  printf("ok\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_integer_to_quantity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    0xebd(%rip),%rsi
lea    0xeb9(%rip),%rdx
call   1060 <sprintf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x6,-0x44(%rbp)
jge    1197 <test_integer_to_quantity+0x57>
mov    -0x44(%rbp),%eax
add    $0x4,%eax
cltq
movb   $0x30,-0x40(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1172 <test_integer_to_quantity+0x32>
mov    -0x44(%rbp),%eax
add    $0x4,%eax
cltq
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <integer_to_quantity@plt>
movsbl -0x20(%rbp),%eax
cmp    $0x31,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsbl -0x1f(%rbp),%eax
cmp    $0x32,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsbl -0x1e(%rbp),%eax
cmp    $0x2e,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x39,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsbl -0x1c(%rbp),%eax
cmp    $0x35,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x5,-0x44(%rbp)
cmpl   $0xb,-0x44(%rbp)
jge    124d <test_integer_to_quantity+0x10d>
movslq -0x44(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x30,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    121c <test_integer_to_quantity+0xdc>
lea    0xdd0(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_integer_to_quantity>:
sub    $0x38,%rsp
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
movabs $0x3030303035393231,%rax
30 30 30
mov    %rax,0x20(%rsp)
movw   $0x3030,0x28(%rsp)
movb   $0x0,0x2a(%rsp)
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <integer_to_quantity@plt>
xor    %edi,%edi
cmpb   $0x31,(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x32,0x1(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x2e,0x2(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x39,0x3(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x35,0x4(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0x5(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0x6(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0x7(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0x8(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0x9(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0xa(%rsp)
sete   %dil
call   1060 <assert@plt>
lea    0xdf3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"test_integer_to_quantity...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"1295\00"
@.str.3 = [4 x i8] c"ok\0A\00"
define i32 @test_integer_to_quantity() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 4, %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %13
store i8 48, i8* %14
br label %15
15: ; preds = %10
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %7
18: ; preds = %7
%19 = load i32, i32* %3
%20 = add nsw i32 4, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %21
store i8 0, i8* %22
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%25 = call i32 @integer_to_quantity(i8* %23, i8* %24)
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 49
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 1
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 50
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 2
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 46
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 3
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 57
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 4
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 53
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
store i32 5, i32* %3
br label %56
56: ; preds = %68, %18
%57 = load i32, i32* %3
%58 = icmp slt i32 %57, 11
br i1 %58, label %59, label %71
59: ; preds = %56
%60 = load i32, i32* %3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 48
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
br label %68
68: ; preds = %59
%69 = load i32, i32* %3
%70 = add nsw i32 %69, 1
store i32 %70, i32* %3
br label %56
71: ; preds = %56
%72 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [28 x i8] c"test_integer_to_quantity...\00"
@.str.2 = [5 x i8] c"1295\00"
@str = [3 x i8] c"ok\00"
define i32 @test_integer_to_quantity() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 4
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 10
store i8 0, i8* %7
%8 = call i32 @integer_to_quantity(i8* %4, i8* %3)
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 49
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 50
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 2
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 46
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 3
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 57
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 4
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 53
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 5
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 48
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 6
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 48
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 7
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 48
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 8
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 48
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 9
%54 = load i8, i8* %53
%55 = icmp eq i8 %54, 48
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 10
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 48
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 1
}