void fun57db1() {
  printf("func57db1 is called!\n");
  char *string = (char *)swalloc(sizeof(char) * 10);
  if (!string) {
    printf("func57db1: alloc memory fail :(\nerror code: %u", getError());
    return;
  }
  printf("Type at most 9 characters.\n");
  scanf("%s", string);
  printf("You typed those: %s", string);
  swfree(string);
}


x86 assembly (clang, -O0):
<fun57db1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
mov    $0x0,%al
call   1030 <swalloc@plt>
cltq
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    119f <fun57db1+0x4f>
mov    $0x0,%al
call   1060 <getError@plt>
mov    %eax,%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11dc <fun57db1+0x8c>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1050 <swfree@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun57db1>:
push   %rbx
lea    0xedb(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
xor    %eax,%eax
call   1030 <swalloc@plt>
test   %eax,%eax
je     11b9 <fun57db1+0x59>
movslq %eax,%rbx
lea    0xed1(%rip),%rdi
call   1040 <puts@plt>
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
pop    %rbx
jmp    1060 <swfree@plt>
xor    %eax,%eax
call   1070 <getError@plt>
lea    0xe39(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"func57db1 is called!\0A\00"
@.str.1 = [47 x i8] c"func57db1: alloc memory fail :(\0Aerror code: %u\00"
@.str.2 = [28 x i8] c"Type at most 9 characters.\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [20 x i8] c"You typed those: %s\00"
define void @fun57db1() {
%1 = alloca i8*
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i64, ...) bitcast (i32 (...)* @swalloc to i32 (i64, ...)*)(i64 10)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = icmp ne i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i32 (...) @getError()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %19
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8*, i8** %1
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %1
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @swfree to i32 (i8*, ...)*)(i8* %17)
br label %19
19: ; preds = %11, %8
ret void
}

LLVM IR (-O2):
@.str.1 = [47 x i8] c"func57db1: alloc memory fail :(\0Aerror code: %u\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [20 x i8] c"You typed those: %s\00"
@str = [21 x i8] c"func57db1 is called!\00"
@str.5 = [27 x i8] c"Type at most 9 characters.\00"
define void @fun57db1() {
%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 10)
%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 %14
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%13 = tail call i32 (i8*, ...) bitcast (i32 (...)* @swfree to i32 (i8*, ...)*)(i8* %4)
br label %14
14: ; preds = %9, %6
ret void
}