#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*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, unsigned char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
void main() {
  char line[100], *sub_text;
  strcpy(line, "hello, I am a string;");
  printf("Line: %s\n", line);
  strcat(line, " what are you?");
  printf("Line: %s\n", line);
  printf("Length of line: %d\n", (int)strlen(line));
  if ((sub_text = strchr(line, 'W')) != NULL) {
    printf("String starting with \"W\" -> %s\n", sub_text);
  }
  if ((sub_text = strchr(line, 'w')) != NULL) {
    printf("String starting with \"w\" -> %s\n", sub_text);
  }
  if ((sub_text = strchr(line, 'u')) != NULL) {
    printf("String starting with \"w\" -> %s\n", sub_text);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    -0x70(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x70(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x57,%esi
call   1050 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
je     11e6 <main+0x96>
mov    -0x78(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x77,%esi
call   1050 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
je     1214 <main+0xc4>
mov    -0x78(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x75,%esi
call   1050 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
je     1242 <main+0xf2>
mov    -0x78(%rbp),%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xea2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xea6(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x57,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d4 <main+0x84>
lea    0xe79(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rdi
mov    $0x77,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11f7 <main+0xa7>
lea    0xe76(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rdi
mov    $0x75,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     121a <main+0xca>
lea    0xe53(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"hello, I am a string;\00"
@.str.1 = [10 x i8] c"Line: %s\0A\00"
@.str.2 = [15 x i8] c" what are you?\00"
@.str.3 = [20 x i8] c"Length of line: %d\0A\00"
@.str.4 = [32 x i8] c"String starting with \22W\22 -> %s\0A\00"
@.str.5 = [32 x i8] c"String starting with \22w\22 -> %s\0A\00"
define void @main() {
%1 = alloca [100 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = trunc i64 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%16 = call i8* @strchr(i8* %15, i8 zeroext 87)
store i8* %16, i8** %2
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = load i8*, i8** %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%23 = call i8* @strchr(i8* %22, i8 zeroext 119)
store i8* %23, i8** %2
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i8*, i8** %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %21
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%30 = call i8* @strchr(i8* %29, i8 zeroext 117)
store i8* %30, i8** %2
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i8*, i8** %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %32, %28
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"hello, I am a string;\00"
@.str.1 = [10 x i8] c"Line: %s\0A\00"
@.str.2 = [15 x i8] c" what are you?\00"
@.str.3 = [20 x i8] c"Length of line: %d\0A\00"
@.str.4 = [32 x i8] c"String starting with \22W\22 -> %s\0A\00"
@.str.5 = [32 x i8] c"String starting with \22w\22 -> %s\0A\00"
define void @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = call i64 @strlen(i8* %2)
%8 = trunc i64 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = call i8* @strchr(i8* %2, i8 zeroext 87)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %10)
br label %14
14: ; preds = %12, %0
%15 = call i8* @strchr(i8* %2, i8 zeroext 119)
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %15)
br label %19
19: ; preds = %17, %14
%20 = call i8* @strchr(i8* %2, i8 zeroext 117)
%21 = icmp eq i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %20)
br label %24
24: ; preds = %22, %19
ret void
}