#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 BASM_PP_Line(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int BASM_PP_Expand2(char *src, char *dst) {
  char lbuf[4096];
  int i, ni;
  strcpy(lbuf, src);
  i = 1;
  ni = 0;
  while (i > 0) {
    i = BASM_PP_Line(lbuf);
    if (i > 0)
      ni++;
  }
  strcpy(dst, lbuf);
  return (ni);
}


x86 assembly (clang, -O0):
<BASM_PP_Expand2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x1014(%rbp)
movl   $0x0,-0x1018(%rbp)
cmpl   $0x0,-0x1014(%rbp)
jle    1197 <BASM_PP_Expand2+0x77>
lea    -0x1010(%rbp),%rdi
call   1040 <BASM_PP_Line@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
jle    1192 <BASM_PP_Expand2+0x72>
mov    -0x1018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1018(%rbp)
jmp    1157 <BASM_PP_Expand2+0x37>
mov    -0x10(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x1018(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BASM_PP_Expand2>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <BASM_PP_Line@plt>
add    $0x1,%ebp
test   %eax,%eax
jg     1150 <BASM_PP_Expand2+0x30>
setg   %bl
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
movzbl %bl,%eax
add    %ebp,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @BASM_PP_Expand2(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [4096 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = call i32 @strcpy(i8* %8, i8* %9)
store i32 1, i32* %6
store i32 0, i32* %7
br label %11
11: ; preds = %22, %2
%12 = load i32, i32* %6
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%16 = call i32 @BASM_PP_Line(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %22
22: ; preds = %19, %14
br label %11
23: ; preds = %11
%24 = load i8*, i8** %4
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
define i32 @BASM_PP_Expand2(i8* %0, i8* %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 0, %2 ], [ %11, %6 ]
%8 = call i32 @BASM_PP_Line(i8* %4)
%9 = icmp sgt i32 %8, 0
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %7, %10
br i1 %9, label %6, label %12
12: ; preds = %6
%13 = call i32 @strcpy(i8* %1, i8* %4)
ret i32 %11
}