#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strequal(char *, char *);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char *buf = (char *)malloc(10);
  *buf = 'a';
  *(buf + 1) = 'b';
  *(buf + 2) = 'c';
  *(buf + 3) = '\0';
  if (strequal(buf, "abc")) {
    printf("Equal\n");
  }
  printf("%d\n", (int)strlen(buf));
  printf("%s\n", buf);
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x61,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x62,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x63,0x2(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1070 <strequal@plt>
cmp    $0x0,%rax
je     11bb <main+0x6b>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xa,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
movl   $0x636261,(%rax)
lea    0xe85(%rip),%rsi
mov    %rax,%rdi
call   1080 <strequal@plt>
test   %rax,%rax
je     1194 <main+0x34>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [7 x i8] c"Equal\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 @malloc(i32 10)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
store i8 97, i8* %9
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8 98, i8* %11
%12 = load i8*, i8** %6
%13 = getelementptr inbounds i8, i8* %12, i64 2
store i8 99, i8* %13
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 3
store i8 0, i8* %15
%16 = load i8*, i8** %6
%17 = call i64 @strequal(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %2
%22 = load i8*, i8** %6
%23 = call i64 @strlen(i8* %22)
%24 = trunc i64 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @free(i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [6 x i8] c"Equal\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 10)
%4 = inttoptr i64 %3 to i8*
store i8 97, i8* %4
%5 = getelementptr inbounds i8, i8* %4, i64 1
store i8 98, i8* %5
%6 = getelementptr inbounds i8, i8* %4, i64 2
store i8 99, i8* %6
%7 = getelementptr inbounds i8, i8* %4, i64 3
store i8 0, i8* %7
%8 = tail call i64 @strequal(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = tail call i64 @strlen(i8* %4)
%14 = trunc i64 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = tail call i32 @puts(i8* %4)
%17 = tail call i32 @free(i8* %4)
ret i32 0
}