#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_text(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int test_pad_text() {
  char str[20];
  int i;
  printf("test_pad_text...");
  sprintf(str, "%s", "text");
  assert(strlen(str) == 4);
  pad_text(str, 16);
  assert(strlen(str) == 16);
  for (i = 5; i < 16; i++) {
    assert(str[i] == ' ');
  }
  printf("ok\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_pad_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xea2(%rip),%rsi
lea    0xe9e(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1070 <pad_text@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x10,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x5,-0x24(%rbp)
cmpl   $0x10,-0x24(%rbp)
jge    11f3 <test_pad_text+0xa3>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x20,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c2 <test_pad_text+0x72>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pad_text>:
push   %rbx
sub    $0x20,%rsp
lea    0xea4(%rip),%rdi
call   1050 <printf@plt>
movl   $0x74786574,(%rsp)
movb   $0x0,0x4(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <pad_text@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    $0x10,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x5(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x6(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x7(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x8(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0x9(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0xa(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0xb(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0xc(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0xd(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0xe(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x20,0xf(%rsp)
sete   %dil
call   1060 <assert@plt>
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret

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