#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*/ pad_value(char *, char *, int const, int const);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int const strlen(char *);
int test_pad_value() {
  char str[30], padded[30];
  int i;
  const int leading_spaces = 8;
  const int trailing_zeros = 5;
  printf("test_pad_value...");
  sprintf(str, "%s", "7.35");
  assert(strlen(str) == 4);
  pad_value(str, padded, leading_spaces, trailing_zeros);
  assert(strlen(padded) == leading_spaces + trailing_zeros);
  for (i = 0; i < leading_spaces - 2; i++) {
    assert(padded[i] == ' ');
  }
  for (i = leading_spaces + 2; i < leading_spaces + trailing_zeros; i++) {
    assert(padded[i] == '0');
  }
  printf("ok\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_pad_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x8,-0x48(%rbp)
movl   $0x5,-0x4c(%rbp)
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe95(%rip),%rsi
lea    0xe91(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x8,%edx
mov    $0x5,%ecx
call   1030 <pad_value@plt>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xd,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x6,-0x44(%rbp)
jge    120a <test_pad_value+0xba>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11d9 <test_pad_value+0x89>
movl   $0xa,-0x44(%rbp)
cmpl   $0xd,-0x44(%rbp)
jge    1242 <test_pad_value+0xf2>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x30,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1211 <test_pad_value+0xc1>
lea    0xdd1(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pad_value>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xea2(%rip),%rdi
call   1060 <printf@plt>
movl   $0x35332e37,0x20(%rsp)
35
movb   $0x0,0x24(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1070 <assert@plt>
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
mov    $0x5,%ecx
call   1040 <pad_value@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
xor    %edi,%edi
cmp    $0xd,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x1(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x2(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x3(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x4(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x5(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0xa(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0xb(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x30,0xc(%rsp)
sete   %dil
call   1070 <assert@plt>
lea    0xdc8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"test_pad_value...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"7.35\00"
@.str.3 = [4 x i8] c"ok\0A\00"
define i32 @test_pad_value() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 8, i32* %4
store i32 5, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, 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))
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp eq i32 %10, 4
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%16 = call i32 @pad_value(i8* %14, i8* %15, i32 8, i32 5)
%17 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = icmp eq i32 %18, 13
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
store i32 0, i32* %3
br label %22
22: ; preds = %34, %0
%23 = load i32, i32* %3
%24 = icmp slt i32 %23, 6
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 32
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
br label %34
34: ; preds = %25
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %22
37: ; preds = %22
store i32 10, i32* %3
br label %38
38: ; preds = %50, %37
%39 = load i32, i32* %3
%40 = icmp slt i32 %39, 13
br i1 %40, label %41, label %53
41: ; preds = %38
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 48
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
br label %50
50: ; preds = %41
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %38
53: ; preds = %38
%54 = 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 = [18 x i8] c"test_pad_value...\00"
@.str.2 = [5 x i8] c"7.35\00"
@str = [3 x i8] c"ok\00"
define i32 @test_pad_value() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strlen(i8* %3)
%7 = icmp eq i32 %6, 4
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @pad_value(i8* %3, i8* %4, i32 8, i32 5)
%11 = call i32 @strlen(i8* %4)
%12 = icmp eq i32 %11, 13
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8, i8* %4
%16 = icmp eq i8 %15, 32
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 32
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 2
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 32
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 3
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 32
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 4
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 32
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 5
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 32
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 10
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 48
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 11
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 48
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 12
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 48
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 1
}