#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*/ addword(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void makeword() {
  char s[80];
  char t[80];
  char *y;
  unsigned int size = 1024;
  y = (char *)malloc(size);
  scanf("%s", s);
  strcpy(y, "");
  scanf("%s", t);
  while (strcmp(t, ";")) {
    if ((strlen(y) + strlen(t)) > size) {
      printf("out of memory\n");
      exit(0);
    }
    strcat(y, t);
    strcat(y, " ");
    scanf("%s", t);
  }
  {
    char *n = (char *)malloc(strlen(y) + 1);
    strcpy(n, y);
    free(y);
    y = n;
  }
  addword(s, y, 0);
}


x86 assembly (clang, -O0):
<makeword>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x400,-0xac(%rbp)
mov    -0xac(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0xa8(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe2e(%rip),%rdi
call   10a0 <scanf@plt>
mov    -0xa8(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa0(%rbp),%rsi
lea    0xe08(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     129f <makeword+0xff>
mov    -0xa8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xbc(%rbp)
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xbc(%rbp),%eax
add    %ecx,%eax
cmp    -0xac(%rbp),%eax
jbe    1261 <makeword+0xc1>
lea    0xdb0(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0xa8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0xa8(%rbp),%rdi
lea    0xd92(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd6b(%rip),%rdi
call   10a0 <scanf@plt>
jmp    11fd <makeword+0x5d>
mov    -0xa8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xb8(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
xor    %edx,%edx
call   1080 <addword@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeword>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
lea    0xe3b(%rip),%r15
lea    0x50(%rsp),%rsi
mov    %r15,%rdi
call   10a0 <scanf@plt>
lea    0xe2d(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10a0 <scanf@plt>
lea    0xe0d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     126c <makeword+0xcc>
mov    %rsp,%rbx
lea    0xdf8(%rip),%r15
lea    0xdec(%rip),%r12
lea    0xde8(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
add    %ebp,%eax
cmp    $0x401,%eax
jae    12b3 <makeword+0x113>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10b0 <strcat@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10a0 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1220 <makeword+0x80>
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0x50(%rsp),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1080 <addword@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd4d(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c";\00"
@.str.3 = [15 x i8] c"out of memory\0A\00"
@.str.4 = [2 x i8] c" \00"
define void @makeword() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i32 1024, i32* %4
%6 = load i32, i32* %4
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %3
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %30, %0
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %38
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = add nsw i32 %21, %23
%25 = load i32, i32* %4
%26 = icmp ugt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %19
%31 = load i8*, i8** %3
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%33 = call i32 @strcat(i8* %31, i8* %32)
%34 = load i8*, i8** %3
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %36)
br label %15
38: ; preds = %15
%39 = load i8*, i8** %3
%40 = call i32 @strlen(i8* %39)
%41 = add nsw i32 %40, 1
%42 = call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to i8*
store i8* %43, i8** %5
%44 = load i8*, i8** %5
%45 = load i8*, i8** %3
%46 = call i32 @strcpy(i8* %44, i8* %45)
%47 = load i8*, i8** %3
%48 = call i32 @free(i8* %47)
%49 = load i8*, i8** %5
store i8* %49, i8** %3
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%51 = load i8*, i8** %3
%52 = call i32 @addword(i8* %50, i8* %51, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c";\00"
@.str.4 = [2 x i8] c" \00"
@str = [14 x i8] c"out of memory\00"
define void @makeword() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i64 @malloc(i32 1024)
%6 = inttoptr i64 %5 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%10 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %26, label %12
12: ; preds = %0, %20
%13 = call i32 @strlen(i8* %6)
%14 = call i32 @strlen(i8* %4)
%15 = add nsw i32 %14, %13
%16 = icmp ugt i32 %15, 1024
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %12
%21 = call i32 @strcat(i8* %6, i8* %4)
%22 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%24 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %12
26: ; preds = %20, %0
%27 = call i32 @strlen(i8* %6)
%28 = add nsw i32 %27, 1
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
%31 = call i32 @strcpy(i8* %30, i8* %6)
%32 = call i32 @free(i8* %6)
%33 = call i32 @addword(i8* %3, i8* %30, i32 0)
ret void
}