#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  char *r = "winnie";
  char *s;
  char q[256];
  int stat;
  s = (char *)malloc(sizeof(char) * 256);
  strcpy(s, "tigger");
  strcpy(q, "pooh");
  printf("String r = %s length of r = %lu\n", r, strlen(r));
  strcpy(q, r);
  strcat(s, r);
  printf("r = %s s = %s q = %s \n", r, s, q);
  stat = strcmp(r, s);
  if (stat < 0)
    printf("r < s (lexicographically)\n");
  else if (stat == 0)
    printf("r == s (lexicographically)\n");
  else
    printf("r > s (lexicographically)\n");
  free(s);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x130(%rbp),%rsi
mov    %eax,%edx
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcmp@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jge    1266 <main+0xe6>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1299 <main+0x119>
cmpl   $0x0,-0x124(%rbp)
jne    1286 <main+0x106>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1294 <main+0x114>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1299 <main+0x119>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xe57(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xe4f(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
lea    0xe2f(%rip),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0xe33(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
lea    0xe2b(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
lea    0xe38(%rip),%rax
lea    0xe17(%rip),%rcx
cmove  %rax,%rcx
lea    0xe41(%rip),%rdi
cmovns %rcx,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"winnie\00"
@.str.1 = [7 x i8] c"tigger\00"
@.str.2 = [5 x i8] c"pooh\00"
@.str.3 = [33 x i8] c"String r = %s length of r = %lu\0A\00"
@.str.4 = [23 x i8] c"r = %s s = %s q = %s \0A\00"
@.str.5 = [27 x i8] c"r < s (lexicographically)\0A\00"
@.str.6 = [28 x i8] c"r == s (lexicographically)\0A\00"
@.str.7 = [27 x i8] c"r > s (lexicographically)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [256 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = call i64 @malloc(i32 256)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = load i8*, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %12, i32 %14)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %3
%20 = load i8*, i8** %2
%21 = call i32 @strcat(i8* %19, i8* %20)
%22 = load i8*, i8** %2
%23 = load i8*, i8** %3
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %22, i8* %23, i8* %24)
%26 = load i8*, i8** %2
%27 = load i8*, i8** %3
%28 = call i32 @strcmp(i8* %26, i8* %27)
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %41
33: ; preds = %0
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %40
38: ; preds = %33
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40, %31
%42 = load i8*, i8** %3
%43 = call i32 @free(i8* %42)
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"winnie\00"
@.str.1 = [7 x i8] c"tigger\00"
@.str.2 = [5 x i8] c"pooh\00"
@.str.3 = [33 x i8] c"String r = %s length of r = %lu\0A\00"
@.str.4 = [23 x i8] c"r = %s s = %s q = %s \0A\00"
@str = [26 x i8] c"r > s (lexicographically)\00"
@str.8 = [27 x i8] c"r == s (lexicographically)\00"
@str.9 = [26 x i8] c"r < s (lexicographically)\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i64 @malloc(i32 256)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %2)
%12 = call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %4)
%13 = icmp slt i32 %12, 0
%14 = icmp eq i32 %12, 0
%15 = select i1 %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0)
%16 = select i1 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0), i8* %15
%17 = call i32 @puts(i8* dereferenceable(1) %16)
%18 = call i32 @free(i8* %4)
%19 = call i32 @exit(i32 0)
unreachable
}