#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*/ role;
typedef int /*<<< orphan*/ reason;
typedef int /*<<< orphan*/ feature;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *getFileLocation(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strip(char *);
scalar_t__ writeStory(int /*<<< orphan*/, int /*<<< orphan*/,
                      int /*<<< orphan*/);
void writer() {
  char role[16];
  char feature[64];
  char reason[64];
  while (1) {
    printf("As a ");
    fgets(role, sizeof(role), stdin);
    printf("I can ");
    fgets(feature, sizeof(feature), stdin);
    printf("so that ");
    fgets(reason, sizeof(reason), stdin);
    if (writeStory(strip(role), strip(feature), strip(reason)) > 0) {
      printf("\n\x1B[32m>>> Wrote a user story to %s\n\n\x1B[0m",
             getFileLocation(0));
    } else {
      printf("\n\x1B[31m!!! can't write user story to %s\n\n\x1B[0m",
             getFileLocation(0));
    }
  }
}


x86 assembly (clang, -O0):
<writer>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   1070 <fgets@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1070 <fgets@plt>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1070 <fgets@plt>
lea    -0x10(%rbp),%rdi
call   1060 <strip@plt>
mov    %eax,-0x98(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <strip@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strip@plt>
mov    -0x98(%rbp),%edi
mov    -0x94(%rbp),%esi
mov    %eax,%edx
call   1030 <writeStory@plt>
cmp    $0x0,%rax
jle    1231 <writer+0xe1>
xor    %edi,%edi
call   1050 <getFileLocation@plt>
mov    %rax,%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1249 <writer+0xf9>
xor    %edi,%edi
call   1050 <getFileLocation@plt>
mov    %rax,%rsi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115b <writer+0xb>

x86 assembly (clang, -O2):
<writer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0x2e80(%rip),%r12
lea    0x50(%rsp),%r13
lea    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <fgets@plt>
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edx
mov    %r13,%rdi
mov    $0x40,%esi
call   1070 <fgets@plt>
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edx
mov    %rbp,%rdi
mov    $0x40,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1060 <strip@plt>
mov    %eax,%r14d
mov    %r13,%rdi
call   1060 <strip@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1060 <strip@plt>
mov    %r14d,%edi
mov    %r15d,%esi
mov    %eax,%edx
call   1030 <writeStory@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1050 <getFileLocation@plt>
test   %rbx,%rbx
lea    0xe20(%rip),%rdi
lea    0xdf0(%rip),%rcx
cmovg  %rcx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <writer+0x30>

LLVM IR (-O0):
@.str = [6 x i8] c"As a \00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"I can \00"
@.str.2 = [9 x i8] c"so that \00"
@.str.3 = [41 x i8] c"\0A\1B[32m>>> Wrote a user story to %s\0A\0A\1B[0m\00"
@.str.4 = [45 x i8] c"\0A\1B[31m!!! can't write user story to %s\0A\0A\1B[0m\00"
define void @writer() {
%1 = alloca [16 x i8]
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
br label %4
4: ; preds = %0, %31
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 16, i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 64, i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %14, i32 64, i32 %15)
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%18 = call i32 @strip(i8* %17)
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%20 = call i32 @strip(i8* %19)
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%22 = call i32 @strip(i8* %21)
%23 = call i64 @writeStory(i32 %18, i32 %20, i32 %22)
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %4
%26 = call i8* @getFileLocation(i32 0)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %31
28: ; preds = %4
%29 = call i8* @getFileLocation(i32 0)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %25
br label %4
}

LLVM IR (-O2):
@.str = [6 x i8] c"As a \00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"I can \00"
@.str.2 = [9 x i8] c"so that \00"
@.str.3 = [41 x i8] c"\0A\1B[32m>>> Wrote a user story to %s\0A\0A\1B[0m\00"
@.str.4 = [45 x i8] c"\0A\1B[31m!!! can't write user story to %s\0A\0A\1B[0m\00"
define void @writer() {
%1 = alloca [16 x i8]
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %7, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %4, i32 16, i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %5, i32 64, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %6, i32 64, i32 %15)
%17 = call i32 @strip(i8* %4)
%18 = call i32 @strip(i8* %5)
%19 = call i32 @strip(i8* %6)
%20 = call i64 @writeStory(i32 %17, i32 %18, i32 %19)
%21 = icmp sgt i64 %20, 0
%22 = call i8* @getFileLocation(i32 0)
%23 = select i1 %21, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23, i8* %22)
br label %7
}