#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*/ message;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ tcc_tca_log(int, char *, char *);
void coreCli_log() {
  int logLevel = 0;
  printf("log level?\n>> ");
  scanf("%i", &logLevel);
  getchar();
  char message[256];
  printf("log message? (max. 255)\n>> ");
  fgets(message, sizeof(message), stdin);
  tcc_tca_log(logLevel, "tcc:module", message);
}


x86 assembly (clang, -O0):
<coreCli_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1040 <fgets@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rdx
lea    0xe72(%rip),%rsi
call   1060 <tcc_tca_log@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coreCli_log>:
push   %rbx
sub    $0x110,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
mov    0xc(%rsp),%edi
lea    0xe78(%rip),%rsi
mov    %rbx,%rdx
call   1060 <tcc_tca_log@plt>
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"log level?\0A>> \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [28 x i8] c"log message? (max. 255)\0A>> \00"
@stdin = global i32 0
@.str.3 = [11 x i8] c"tcc:module\00"
define void @coreCli_log() {
%1 = alloca i32
%2 = alloca [256 x i8]
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 (...) @getchar()
%6 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 256, i32 %8)
%10 = load i32, i32* %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%12 = call i32 @tcc_tca_log(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %11)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"log level?\0A>> \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [28 x i8] c"log message? (max. 255)\0A>> \00"
@stdin = global i32 0
@.str.3 = [11 x i8] c"tcc:module\00"
define void @coreCli_log() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 (...) @getchar()
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %7, i32 256, i32 %9)
%11 = load i32, i32* %1
%12 = call i32 @tcc_tca_log(i32 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %7)
ret void
}