#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main() {
  printf("Enter two String of Length less than %d \n", 30);
  char ch, str1[30], str2[30];
  int i = 0;
  while ((ch = getchar()) != '\n' && i < 30)
    str1[i++] = ch;
  i = 0;
  while ((ch = getchar()) != '\n' && i < 30)
    str2[i++] = ch;
  int len = (strlen(str1) > strlen(str2) ? strlen(str2) : strlen(str1));
  if (strncmp(str1, str2, len) > 0)
    printf("Greater Than 0 \n");
  else if (strncmp(str1, str2, len) == 0)
    printf("Equal to 0 \n");
  else
    printf("Less Than 0 \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x1e,%esi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x54(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x59(%rbp)
je     118e <main+0x4e>
cmpl   $0x1e,-0x54(%rbp)
setl   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    119e <main+0x5e>
jmp    11b7 <main+0x77>
mov    -0x5(%rbp),%cl
mov    -0x54(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
cltq
mov    %cl,-0x30(%rbp,%rax,1)
jmp    1169 <main+0x29>
movl   $0x0,-0x54(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x5a(%rbp)
je     11e3 <main+0xa3>
cmpl   $0x1e,-0x54(%rbp)
setl   %al
mov    %al,-0x5a(%rbp)
mov    -0x5a(%rbp),%al
test   $0x1,%al
jne    11f3 <main+0xb3>
jmp    120c <main+0xcc>
mov    -0x5(%rbp),%cl
mov    -0x54(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
cltq
mov    %cl,-0x50(%rbp,%rax,1)
jmp    11be <main+0x7e>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
cmp    %ecx,%eax
jle    123f <main+0xff>
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x64(%rbp)
jmp    124b <main+0x10b>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x58(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jle    127e <main+0x13e>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12be <main+0x17e>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12ab <main+0x16b>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12b9 <main+0x179>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12be <main+0x17e>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xea0(%rip),%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
je     119c <main+0x4c>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %al,0x20(%rsp,%rbx,1)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
je     119c <main+0x4c>
lea    0x1(%rbx),%rcx
cmp    $0x1d,%rbx
mov    %rcx,%rbx
jb     1180 <main+0x30>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
je     11cb <main+0x7b>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %al,(%rsp,%rbx,1)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
je     11cb <main+0x7b>
lea    0x1(%rbx),%rcx
cmp    $0x1d,%rbx
mov    %rcx,%rbx
jb     11b0 <main+0x60>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %rsp,%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebx
mov    %r14,%rdi
cmovg  %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jle    1210 <main+0xc0>
lea    0xe35(%rip),%rdi
jmp    1234 <main+0xe4>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
mov    %ebx,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
lea    0xe0e(%rip),%rax
lea    0xdfa(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Enter two String of Length less than %d \0A\00"
@.str.1 = [17 x i8] c"Greater Than 0 \0A\00"
@.str.2 = [13 x i8] c"Equal to 0 \0A\00"
@.str.3 = [14 x i8] c"Less Than 0 \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [30 x i8]
%4 = alloca [30 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 30)
store i32 0, i32* %5
br label %8
8: ; preds = %17, %0
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 30
br label %15
15: ; preds = %12, %8
%16 = phi i1 [ false, %8 ], [ %14, %12 ]
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = load i8, i8* %2
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %21
store i8 %18, i8* %22
br label %8
23: ; preds = %15
store i32 0, i32* %5
br label %24
24: ; preds = %33, %23
%25 = call signext i8 (...) @getchar()
store i8 %25, i8* %2
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 10
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 30
br label %31
31: ; preds = %28, %24
%32 = phi i1 [ false, %24 ], [ %30, %28 ]
br i1 %32, label %33, label %39
33: ; preds = %31
%34 = load i8, i8* %2
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %37
store i8 %34, i8* %38
br label %24
39: ; preds = %31
%40 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
%42 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = icmp sgt i32 %41, %43
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
br label %51
48: ; preds = %39
%49 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
br label %51
51: ; preds = %48, %45
%52 = phi i32 [ %47, %45 ], [ %50, %48 ]
store i32 %52, i32* %6
%53 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%54 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%55 = load i32, i32* %6
%56 = call i64 @strncmp(i8* %53, i8* %54, i32 %55)
%57 = icmp sgt i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %51
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %71
60: ; preds = %51
%61 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%62 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%63 = load i32, i32* %6
%64 = call i64 @strncmp(i8* %61, i8* %62, i32 %63)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %70
68: ; preds = %60
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %70
70: ; preds = %68, %66
br label %71
71: ; preds = %70, %58
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Enter two String of Length less than %d \0A\00"
@str = [13 x i8] c"Less Than 0 \00"
@str.4 = [12 x i8] c"Equal to 0 \00"
@str.5 = [16 x i8] c"Greater Than 0 \00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 30)
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %8, label %11
8: ; preds = %11, %0
%9 = tail call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %29, label %20
11: ; preds = %0, %11
%12 = phi i64 [ %14, %11 ], [ 0, %0 ]
%13 = phi i8 [ %16, %11 ], [ %6, %0 ]
%14 = add nuw nsw i64 %12, 1
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %12
store i8 %13, i8* %15
%16 = tail call signext i8 (...) @getchar()
%17 = icmp ne i8 %16, 10
%18 = icmp ult i64 %12, 29
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %11, label %8
20: ; preds = %8, %20
%21 = phi i64 [ %23, %20 ], [ 0, %8 ]
%22 = phi i8 [ %25, %20 ], [ %9, %8 ]
%23 = add nuw nsw i64 %21, 1
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %21
store i8 %22, i8* %24
%25 = tail call signext i8 (...) @getchar()
%26 = icmp ne i8 %25, 10
%27 = icmp ult i64 %21, 29
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %20, label %29
29: ; preds = %20, %8
%30 = call i32 @strlen(i8* %4)
%31 = call i32 @strlen(i8* %5)
%32 = icmp sgt i32 %30, %31
%33 = select i1 %32, i8* %5, i8* %4
%34 = call i32 @strlen(i8* %33)
%35 = call i64 @strncmp(i8* %4, i8* %5, i32 %34)
%36 = icmp sgt i64 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %29
%38 = call i64 @strncmp(i8* %4, i8* %5, i32 %34)
%39 = icmp eq i64 %38, 0
%40 = select i1 %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0)
br label %41
41: ; preds = %37, %29
%42 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0), %29 ], [ %40, %37 ]
%43 = call i32 @puts(i8* dereferenceable(1) %42)
ret i32 0
}