#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ add(char **, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
void build(char *prefix[], FILE *f) {
  char buf[100], fmt[10];
  sprintf(fmt, "%%%ds", sizeof(buf) - 1);
  while (fscanf(f, fmt, buf) != EOF) {
    char *t = (char *)malloc(strlen(buf) + 1);
    strcpy(t, buf);
    add(prefix, t);
  }
}


x86 assembly (clang, -O0):
<build>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x8a(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x63,%edx
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x8a(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1060 <fscanf@plt>
mov    0x2e42(%rip),%rcx
cmp    (%rcx),%rax
je     11f0 <build+0x90>
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1030 <add@plt>
jmp    118b <build+0x2b>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe85(%rip),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x63,%edx
call   1080 <sprintf@plt>
lea    0x10(%rsp),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fscanf@plt>
mov    0x2e44(%rip),%rbp
cmp    0x0(%rbp),%rax
je     11fe <build+0x9e>
lea    0x10(%rsp),%r13
lea    0x6(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <add@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <fscanf@plt>
cmp    0x0(%rbp),%rax
jne    11c0 <build+0x60>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%%%ds\00"
@EOF = global i64 0
define void @build(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca [100 x i8]
%6 = alloca [10 x i8]
%7 = alloca i8*
store i8** %0, i8*** %3
store i32* %1, i32** %4
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 99)
br label %10
10: ; preds = %17, %2
%11 = load i32*, i32** %4
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%14 = call i64 @fscanf(i32* %11, i8* %12, i8* %13)
%15 = load i64, i64* @EOF
%16 = icmp ne i64 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %10
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%19 = call i64 @strlen(i8* %18)
%20 = add nsw i64 %19, 1
%21 = call i64 @malloc(i64 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8**, i8*** %3
%27 = load i8*, i8** %7
%28 = call i32 @add(i8** %26, i8* %27)
br label %10
29: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%%%ds\00"
@EOF = global i64 0
define void @build(i8** %0, i32* nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 99)
%8 = call i64 @fscanf(i32* %1, i8* %6, i8* %5)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %21, label %11
11: ; preds = %2, %11
%12 = call i64 @strlen(i8* %5)
%13 = add nsw i64 %12, 1
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i8*
%16 = call i32 @strcpy(i8* %15, i8* %5)
%17 = call i32 @add(i8** %0, i8* %15)
%18 = call i64 @fscanf(i32* %1, i8* %6, i8* %5)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %11
21: ; preds = %11, %2
ret void
}