#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*/ puts(char *);
int /*<<< orphan*/ s_gets(char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int main(void) {
  char flower[30];
  char addon[] = "s smell like old shoes.";
  char bug[13];
  int available;
  puts("What is your favorite flower?");
  s_gets(flower, 30);
  if ((strlen(addon) + strlen(flower) + 1) <= 30) {
    strcat(flower, addon);
  }
  puts(flower);
  puts("What is your favorite bug?");
  s_gets(bug, 13);
  available = 13 - strlen(bug) - 1;
  strncat(bug, addon, available);
  puts(bug);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
lea    -0x30(%rbp),%rdi
mov    $0x1e,%esi
call   1040 <s_gets@plt>
lea    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x68(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cmp    $0x1e,%eax
jg     11cf <main+0x7f>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x30(%rbp),%rdi
call   1030 <puts@plt>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
lea    -0x5d(%rbp),%rdi
mov    $0xd,%esi
call   1040 <s_gets@plt>
lea    -0x5d(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    $0xd,%eax
sub    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x64(%rbp)
lea    -0x5d(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x64(%rbp),%edx
call   1060 <strncat@plt>
lea    -0x5d(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
movaps 0xea3(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x2e73656f687320,%rax
mov    %rax,0x10(%rsp)
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1040 <s_gets@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    %ebp,%eax
cmp    $0x1d,%eax
jg     11b4 <main+0x64>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
call   1070 <strcat@plt>
lea    0x20(%rsp),%rdi
call   1030 <puts@plt>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0x4b(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xd,%esi
call   1040 <s_gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0xc,%edx
sub    %eax,%edx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <strncat@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.addon = [24 x i8] c"s smell like old shoes.\00"
@.str = [30 x i8] c"What is your favorite flower?\00"
@.str.1 = [27 x i8] c"What is your favorite bug?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca [24 x i8]
%4 = alloca [13 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [24 x i8]* %3 to i8*
%7 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%9 = call i32 @s_gets(i8* %8, i32 30)
%10 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %11, %13
%15 = add nsw i32 %14, 1
%16 = icmp sle i32 %15, 30
br i1 %16, label %17, label %21
17: ; preds = %0
%18 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%20 = call i32 @strcat(i8* %18, i8* %19)
br label %21
21: ; preds = %17, %0
%22 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%23 = call i32 @puts(i8* %22)
%24 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%26 = call i32 @s_gets(i8* %25, i32 13)
%27 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = sub nsw i32 13, %28
%30 = sub nsw i32 %29, 1
store i32 %30, i32* %5
%31 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%32 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%33 = load i32, i32* %5
%34 = call i32 @strncat(i8* %31, i8* %32, i32 %33)
%35 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%36 = call i32 @puts(i8* %35)
ret i32 0
}

LLVM IR (-O2):
@__const.main.addon = [24 x i8] c"s smell like old shoes.\00"
@.str = [30 x i8] c"What is your favorite flower?\00"
@.str.1 = [27 x i8] c"What is your favorite bug?\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [24 x i8]
%3 = alloca [13 x i8]
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @s_gets(i8* %4, i32 30)
%9 = call i32 @strlen(i8* %5)
%10 = call i32 @strlen(i8* %4)
%11 = add nsw i32 %10, %9
%12 = icmp slt i32 %11, 30
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @strcat(i8* %4, i8* %5)
br label %15
15: ; preds = %13, %0
%16 = call i32 @puts(i8* %4)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @s_gets(i8* %6, i32 13)
%19 = call i32 @strlen(i8* %6)
%20 = sub i32 12, %19
%21 = call i32 @strncat(i8* %6, i8* %5, i32 %20)
%22 = call i32 @puts(i8* %6)
ret i32 0
}