#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 */
scalar_t__ endsWith(char *, char);
int /*<<< orphan*/ getLine(char *, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ startsWith(char *, char);
int main() {
  char line[50];
  printf("Please enter expression: ");
  getLine(line, 50);
  if (startsWith(line, '('))
    printf("Line starts with (\n");
  else
    printf("Line does not start with (\n");
  if (endsWith(line, ')'))
    printf("Line ends with )\n");
  else
    printf("Line does not end with )\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x32,%esi
call   1050 <getLine@plt>
lea    -0x40(%rbp),%rdi
mov    $0x28,%esi
call   1030 <startsWith@plt>
cmp    $0x0,%rax
je     1192 <main+0x52>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
jmp    119e <main+0x5e>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x29,%esi
call   1060 <endsWith@plt>
cmp    $0x0,%rax
je     11c7 <main+0x87>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
jmp    11d3 <main+0x93>
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xea4(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1060 <getLine@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
call   1040 <startsWith@plt>
test   %rax,%rax
lea    0xe92(%rip),%rax
lea    0xed0(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x29,%esi
call   1070 <endsWith@plt>
test   %rax,%rax
lea    0xe86(%rip),%rax
lea    0xe98(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Please enter expression: \00"
@.str.1 = [20 x i8] c"Line starts with (\0A\00"
@.str.2 = [28 x i8] c"Line does not start with (\0A\00"
@.str.3 = [18 x i8] c"Line ends with )\0A\00"
@.str.4 = [26 x i8] c"Line does not end with )\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = call i32 @getLine(i8* %4, i32 50)
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%7 = call i64 @startsWith(i8* %6, i8 signext 40)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%15 = call i64 @endsWith(i8* %14, i8 signext 41)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %21
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Please enter expression: \00"
@str = [27 x i8] c"Line does not start with (\00"
@str.5 = [25 x i8] c"Line does not end with )\00"
@str.6 = [17 x i8] c"Line ends with )\00"
@str.7 = [19 x i8] c"Line starts with (\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @getLine(i8* %2, i32 50)
%5 = call i64 @startsWith(i8* %2, i8 signext 40)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0)
%8 = call i32 @puts(i8* dereferenceable(1) %7)
%9 = call i64 @endsWith(i8* %2, i8 signext 41)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0)
%12 = call i32 @puts(i8* dereferenceable(1) %11)
ret i32 0
}