int func32fd3() {
  printf("func32fd3 is called!\n");
  void *tmp = swalloc(sizeof(char) * 1024);
  if (!tmp) {
    unsigned rt = getError();
    printf("func57db1: alloc memory fail :(\nerror code: %u", rt);
    return rt;
  }
  ((char *)tmp)[1023] = '\0';
  printf("%s\n", tmp);
  return *(((int *)tmp) + (*((int *)tmp) % 1024));
}


x86 assembly (clang, -O0):
<func32fd3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x400,%edi
mov    $0x0,%al
call   1030 <swalloc@plt>
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1189 <func32fd3+0x59>
mov    $0x0,%al
call   1050 <getError@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <func32fd3+0x99>
mov    -0x10(%rbp),%rax
movb   $0x0,0x3ff(%rax)
mov    -0x10(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func32fd3>:
push   %rbx
lea    0xee7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x400,%edi
xor    %eax,%eax
call   1030 <swalloc@plt>
test   %eax,%eax
je     118b <func32fd3+0x4b>
movslq %eax,%rbx
movb   $0x0,0x3ff(%rbx)
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    (%rbx),%eax
lea    0x3ff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffc00,%ecx
sub    %ecx,%eax
cltq
mov    (%rbx,%rax,4),%ebx
jmp    11a4 <func32fd3+0x64>
xor    %eax,%eax
call   1060 <getError@plt>
mov    %eax,%ebx
lea    0xe65(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"func32fd3 is called!\0A\00"
@.str.1 = [47 x i8] c"func57db1: alloc memory fail :(\0Aerror code: %u\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @func32fd3() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i64, ...) bitcast (i32 (...)* @swalloc to i32 (i64, ...)*)(i64 1024)
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %0
%11 = call i32 (...) @getError()
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
store i32 %14, i32* %1
br label %29
15: ; preds = %0
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 1023
store i8 0, i8* %17
%18 = load i8*, i8** %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %2
%21 = bitcast i8* %20 to i32*
%22 = load i8*, i8** %2
%23 = bitcast i8* %22 to i32*
%24 = load i32, i32* %23
%25 = srem i32 %24, 1024
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %21, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %1
br label %29
29: ; preds = %15, %10
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [47 x i8] c"func57db1: alloc memory fail :(\0Aerror code: %u\00"
@str = [21 x i8] c"func32fd3 is called!\00"
define i32 @func32fd3() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i64, ...) bitcast (i32 (...)* @swalloc to i32 (i64, ...)*)(i64 1024)
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i32 %2, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = tail call i32 (...) @getError()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %18
9: ; preds = %0
%10 = getelementptr inbounds i8, i8* %4, i64 1023
store i8 0, i8* %10
%11 = tail call i32 @puts(i8* %4)
%12 = inttoptr i64 %3 to i32*
%13 = load i32, i32* %12
%14 = srem i32 %13, 1024
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %12, i64 %15
%17 = load i32, i32* %16
br label %18
18: ; preds = %9, %6
%19 = phi i32 [ %17, %9 ], [ %7, %6 ]
ret i32 %19
}