#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*/ test_lpad(char *, int, char);
int main(void) {
  test_lpad("abc\n"
            "this is a test\n",
            2, ' ');
  test_lpad("abc\n"
            "\na\0\nasdf\n",
            5, ' ');
  test_lpad("\na\0", 2, ' ');
  test_lpad("\na\0", 0, ' ');
  test_lpad("\n\0\n", 3, ' ');
  test_lpad("a\0a", 2, ' ');
  test_lpad("asdfadsf\naefsdf\n", 3, '0');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
mov    $0x2,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xef4(%rip),%rdi
mov    $0x5,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xeec(%rip),%rdi
mov    $0x2,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xed6(%rip),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xec7(%rip),%rdi
mov    $0x3,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xeb5(%rip),%rdi
mov    $0x2,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xe78(%rip),%rdi
mov    $0x3,%esi
mov    $0x30,%edx
call   1030 <test_lpad@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rdi
mov    $0x2,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xef7(%rip),%rdi
mov    $0x5,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xeef(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xecb(%rip),%rdi
mov    $0x3,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xeb9(%rip),%rdi
mov    $0x2,%esi
mov    $0x20,%edx
call   1030 <test_lpad@plt>
lea    0xe7c(%rip),%rdi
mov    $0x3,%esi
mov    $0x30,%edx
call   1030 <test_lpad@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"abc\0Athis is a test\0A\00"
@.str.1 = [14 x i8] c"abc\0A\0Aa\00\0Aasdf\0A\00"
@.str.2 = [4 x i8] c"\0Aa\00\00"
@.str.3 = [4 x i8] c"\0A\00\0A\00"
@.str.4 = [4 x i8] c"a\00a\00"
@.str.5 = [17 x i8] c"asdfadsf\0Aaefsdf\0A\00"
define i32 @main() {
%1 = call i32 @test_lpad(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2, i8 signext 32)
%2 = call i32 @test_lpad(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 5, i8 signext 32)
%3 = call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 2, i8 signext 32)
%4 = call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 0, i8 signext 32)
%5 = call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3, i8 signext 32)
%6 = call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 2, i8 signext 32)
%7 = call i32 @test_lpad(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 3, i8 signext 48)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"abc\0Athis is a test\0A\00"
@.str.1 = [14 x i8] c"abc\0A\0Aa\00\0Aasdf\0A\00"
@.str.2 = [4 x i8] c"\0Aa\00\00"
@.str.3 = [4 x i8] c"\0A\00\0A\00"
@.str.4 = [4 x i8] c"a\00a\00"
@.str.5 = [17 x i8] c"asdfadsf\0Aaefsdf\0A\00"
define i32 @main() {
%1 = tail call i32 @test_lpad(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2, i8 signext 32)
%2 = tail call i32 @test_lpad(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 5, i8 signext 32)
%3 = tail call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 2, i8 signext 32)
%4 = tail call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 0, i8 signext 32)
%5 = tail call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3, i8 signext 32)
%6 = tail call i32 @test_lpad(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 2, i8 signext 32)
%7 = tail call i32 @test_lpad(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 3, i8 signext 48)
ret i32 0
}