#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 */
typedef int /*<<< orphan*/ str3;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(void) {
  char str1[] = "Hacking is not a crime";
  char str2[32];
  strcpy(str2, str1);
  printf("str1 %s - strlen(str1): %d\nstr2 %s - strlen(str2): %d\n", str1,
         strlen(str1), str2, strlen(str2));
  char str3[32];
  strncpy(str3, str2, sizeof(str3) - 1);
  str3[sizeof(str3) - 1] = '\0';
  printf("str3 %s - strlen(str3): %d\n", str3, strlen(str3));
  char strb[] = "is not ";
  char strc[] = "a crime";
  char str5[] = "hacking ";
  strcat(str5, strb);
  strcat(str5, strc);
  printf("str5 %s\n", str5);
  strncat(strb, strc, strlen(strc));
  printf("strb %s\n", strb);
  if (strcmp(strb, strc) > 0)
    printf(" %d < %d\n", strlen(strc), strlen(strb));
  if (strcmp(strc, strb) < 0)
    printf(" %d > %d\n", strlen(strb), strlen(strc));
  if (strcmp(strb, strb) == 0)
    printf(" %d == %d\n", strlen(strb), strlen(strb));
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe74(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe72(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe6c(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xe64(%rip),%al
mov    %al,-0xa(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xa4(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb0(%rbp),%rsi
mov    -0xa4(%rbp),%edx
mov    -0xa0(%rbp),%rcx
mov    %eax,%r8d
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x41(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0xe0d(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe0a(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe07(%rip),%rax
mov    %rax,-0x79(%rbp)
mov    0xe05(%rip),%al
mov    %al,-0x71(%rbp)
lea    -0x79(%rbp),%rdi
lea    -0x68(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x79(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x79(%rbp),%rsi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x68(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
call   1070 <strncat@plt>
lea    -0x68(%rbp),%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x68(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jle    1337 <main+0x1c7>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xb4(%rbp)
lea    -0x68(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb4(%rbp),%esi
mov    %eax,%edx
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x68(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jge    137c <main+0x20c>
lea    -0x68(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xb8(%rbp)
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb8(%rbp),%esi
mov    %eax,%edx
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x68(%rbp),%rdi
lea    -0x68(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    13c1 <main+0x251>
lea    -0x68(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xbc(%rbp)
lea    -0x68(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xbc(%rbp),%esi
mov    %eax,%edx
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x656d6972632061,%r15
mov    %r15,0x2f(%rsp)
lea    0x60(%rsp),%r14
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xe51(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x5f(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe4d(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
movabs $0x20746f6e207369,%rax
mov    %rax,(%rsp)
mov    %r15,0x8(%rsp)
movabs $0x20676e696b636168,%rax
6e 67 20
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
lea    0x10(%rsp),%rbp
mov    %rsp,%r14
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
lea    0x8(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
lea    0xe15(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <strncat@plt>
lea    0xdf8(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jle    12c4 <main+0x154>
lea    0x8(%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
call   1050 <strlen@plt>
lea    0xdcc(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jns    12fc <main+0x18c>
mov    %rsp,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
call   1050 <strlen@plt>
lea    0xd9e(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rdi
mov    %rdi,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1333 <main+0x1c3>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xd71(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str1 = [23 x i8] c"Hacking is not a crime\00"
@.str = [55 x i8] c"str1 %s - strlen(str1): %d\0Astr2 %s - strlen(str2): %d\0A\00"
@.str.1 = [28 x i8] c"str3 %s - strlen(str3): %d\0A\00"
@__const.main.strb = [8 x i8] c"is not \00"
@__const.main.strc = [8 x i8] c"a crime\00"
@__const.main.str5 = [9 x i8] c"hacking \00"
@.str.2 = [9 x i8] c"str5 %s\0A\00"
@.str.3 = [9 x i8] c"strb %s\0A\00"
@.str.4 = [10 x i8] c" %d < %d\0A\00"
@.str.5 = [10 x i8] c" %d > %d\0A\00"
@.str.6 = [11 x i8] c" %d == %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [23 x i8]
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [8 x i8]
%6 = alloca [8 x i8]
%7 = alloca [9 x i8]
store i32 0, i32* %1
%8 = bitcast [23 x i8]* %2 to i8*
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %14, i8* %15, i32 %17)
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%21 = call i32 @strncpy(i8* %19, i8* %20, i32 31)
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 31
store i8 0, i8* %22
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %25)
%27 = bitcast [8 x i8]* %5 to i8*
%28 = bitcast [8 x i8]* %6 to i8*
%29 = bitcast [9 x i8]* %7 to i8*
%30 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%35 = call i32 @strcat(i8* %33, i8* %34)
%36 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
%42 = call i32 @strncat(i8* %38, i8* %39, i32 %41)
%43 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%46 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%47 = call i64 @strcmp(i8* %45, i8* %46)
%48 = icmp sgt i64 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %0
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %51, i32 %53)
br label %55
55: ; preds = %49, %0
%56 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%57 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%58 = call i64 @strcmp(i8* %56, i8* %57)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %55
%61 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%62 = call i32 @strlen(i8* %61)
%63 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%64 = call i32 @strlen(i8* %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %62, i32 %64)
br label %66
66: ; preds = %60, %55
%67 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%68 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%69 = call i64 @strcmp(i8* %67, i8* %68)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %66
%72 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%73 = call i32 @strlen(i8* %72)
%74 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%75 = call i32 @strlen(i8* %74)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %73, i32 %75)
br label %77
77: ; preds = %71, %66
%78 = load i32, i32* @EXIT_SUCCESS
ret i32 %78
}

LLVM IR (-O2):
@__const.main.str1 = [23 x i8] c"Hacking is not a crime\00"
@.str = [55 x i8] c"str1 %s - strlen(str1): %d\0Astr2 %s - strlen(str2): %d\0A\00"
@.str.1 = [28 x i8] c"str3 %s - strlen(str3): %d\0A\00"
@__const.main.str5 = [9 x i8] c"hacking \00"
@.str.2 = [9 x i8] c"str5 %s\0A\00"
@.str.3 = [9 x i8] c"strb %s\0A\00"
@.str.4 = [10 x i8] c" %d < %d\0A\00"
@.str.5 = [10 x i8] c" %d > %d\0A\00"
@.str.6 = [11 x i8] c" %d == %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [23 x i8]
%2 = alloca [32 x i8]
%3 = alloca [32 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = alloca [9 x i8]
%7 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* %7)
%10 = call i32 @strlen(i8* %7)
%11 = call i32 @strlen(i8* %8)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %10, i8* %8, i32 %11)
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%14 = call i32 @strncpy(i8* %13, i8* %8, i32 31)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 31
store i8 0, i8* %15
%16 = call i32 @strlen(i8* %13)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 %16)
%18 = bitcast i64* %4 to i8*
store i64 9135221192553321, i64* %4
%19 = bitcast i64* %5 to i8*
store i64 28549272305868897, i64* %5
%20 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* %18)
%22 = call i32 @strcat(i8* %20, i8* %19)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%24 = call i32 @strlen(i8* %19)
%25 = call i32 @strncat(i8* %18, i8* %19, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64* %4)
%27 = call i64 @strcmp(i8* %18, i8* %19)
%28 = icmp sgt i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %0
%30 = call i32 @strlen(i8* %19)
%31 = call i32 @strlen(i8* %18)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %31)
br label %33
33: ; preds = %29, %0
%34 = call i64 @strcmp(i8* %19, i8* %18)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = call i32 @strlen(i8* %18)
%38 = call i32 @strlen(i8* %19)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %37, i32 %38)
br label %40
40: ; preds = %36, %33
%41 = call i64 @strcmp(i8* %18, i8* %18)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = call i32 @strlen(i8* %18)
%45 = call i32 @strlen(i8* %18)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %44, i32 %45)
br label %47
47: ; preds = %43, %40
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}