#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*/ fgets(char *, int, int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ str_copy(char *, char *);
int /*<<< orphan*/ system(char *);
void prob7(void) {
  char string1[100];
  char string2[100];
  int loop;
  system("clear");
  printf("Please enter a string:\n");
  while (getchar() != '\n') {
    ;
  }
  fgets(string1, 100, stdin);
  for (loop = 0; loop < 100; loop++) {
    if (string1[loop] == '\n') {
      string1[loop] = '\0';
      break;
    }
  }
  printf("\nThis is string 1:\n%s\n\n", string1);
  str_copy(string2, string1);
  printf("This is string 2 after being copied:\n%s\n", string2);
  printf("\n\nPress enter to return to the menu.");
  while (getchar() != '\n') {
    ;
  }
}


x86 assembly (clang, -O0):
<prob7>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
lea    0xe9e(%rip),%rdi
call   1030 <system@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     118d <prob7+0x3d>
jmp    1175 <prob7+0x25>
lea    -0x70(%rbp),%rdi
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
movl   $0x0,-0xe4(%rbp)
cmpl   $0x64,-0xe4(%rbp)
jge    11fa <prob7+0xaa>
movslq -0xe4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11e1 <prob7+0x91>
movslq -0xe4(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
jmp    11fa <prob7+0xaa>
jmp    11e6 <prob7+0x96>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    11ae <prob7+0x5e>
lea    -0x70(%rbp),%rsi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1070 <str_copy@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1257 <prob7+0x107>
jmp    123f <prob7+0xef>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prob7>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xe8f(%rip),%rdi
call   1040 <system@plt>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
jne    1190 <prob7+0x30>
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
mov    $0x4,%eax
cs nopw 0x0(%rax,%rax,1)
cmpb   $0xa,-0x4(%rsp,%rax,1)
je     11ee <prob7+0x8e>
cmpb   $0xa,-0x3(%rsp,%rax,1)
je     11f4 <prob7+0x94>
cmpb   $0xa,-0x2(%rsp,%rax,1)
je     11fa <prob7+0x9a>
cmpb   $0xa,-0x1(%rsp,%rax,1)
je     1200 <prob7+0xa0>
cmpb   $0xa,(%rsp,%rax,1)
je     1204 <prob7+0xa4>
add    $0x5,%rax
cmp    $0x68,%rax
jne    11c0 <prob7+0x60>
jmp    120a <prob7+0xaa>
add    $0xfffffffffffffffc,%rax
jmp    1204 <prob7+0xa4>
add    $0xfffffffffffffffd,%rax
jmp    1204 <prob7+0xa4>
add    $0xfffffffffffffffe,%rax
jmp    1204 <prob7+0xa4>
add    $0xffffffffffffffff,%rax
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xdf5(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <str_copy@plt>
lea    0xde9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   (%rax)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
jne    1250 <prob7+0xf0>
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [24 x i8] c"Please enter a string:\0A\00"
@stdin = global i32 0
@.str.2 = [24 x i8] c"\0AThis is string 1:\0A%s\0A\0A\00"
@.str.3 = [41 x i8] c"This is string 2 after being copied:\0A%s\0A\00"
@.str.4 = [37 x i8] c"\0A\0APress enter to return to the menu.\00"
define void @prob7() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %10, %0
%7 = call signext i8 (...) @getchar()
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 100, i32 %13)
store i32 0, i32* %3
br label %15
15: ; preds = %30, %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 100
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %27
store i8 0, i8* %28
br label %33
29: ; preds = %18
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %15
33: ; preds = %25, %15
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%38 = call i32 @str_copy(i8* %36, i8* %37)
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %46, %33
%43 = call signext i8 (...) @getchar()
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 10
br i1 %45, label %46, label %47
46: ; preds = %42
br label %42
47: ; preds = %42
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@stdin = global i32 0
@.str.2 = [24 x i8] c"\0AThis is string 1:\0A%s\0A\0A\00"
@.str.3 = [41 x i8] c"This is string 2 after being copied:\0A%s\0A\00"
@.str.4 = [37 x i8] c"\0A\0APress enter to return to the menu.\00"
@str = [23 x i8] c"Please enter a string:\00"
define void @prob7() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %7, %0
%8 = tail call signext i8 (...) @getchar()
%9 = icmp eq i8 %8, 10
br i1 %9, label %10, label %7
10: ; preds = %7
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %3, i32 100, i32 %11)
br label %13
13: ; preds = %42, %10
%14 = phi i64 [ 0, %10 ], [ %43, %42 ]
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %22
18: ; preds = %37, %32, %27, %22, %13
%19 = phi i64 [ %14, %13 ], [ %23, %22 ], [ %28, %27 ], [ %33, %32 ], [ %38, %37 ]
%20 = and i64 %19, 4294967295
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
store i8 0, i8* %21
br label %45
22: ; preds = %13
%23 = add nuw nsw i64 %14, 1
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 10
br i1 %26, label %18, label %27
27: ; preds = %22
%28 = add nuw nsw i64 %14, 2
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 10
br i1 %31, label %18, label %32
32: ; preds = %27
%33 = add nuw nsw i64 %14, 3
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 10
br i1 %36, label %18, label %37
37: ; preds = %32
%38 = add nuw nsw i64 %14, 4
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 10
br i1 %41, label %18, label %42
42: ; preds = %37
%43 = add nuw nsw i64 %14, 5
%44 = icmp eq i64 %43, 100
br i1 %44, label %45, label %13
45: ; preds = %42, %18
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%47 = call i32 @str_copy(i8* %4, i8* %3)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %50, %45
%51 = call signext i8 (...) @getchar()
%52 = icmp eq i8 %51, 10
br i1 %52, label %53, label %50
53: ; preds = %50
ret void
}