#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int syscall(int, int, char *, int /*<<< orphan*/);
void main() {
  int pid;
  char tag[32] = "";
  printf("pid : ");
  scanf("%d", &pid);
  printf("tag : ");
  scanf("%s", tag);
  int ret = syscall(340, pid, tag, strlen(tag));
  if (ret == 0)
    printf("successfully inserted\n");
  else
    printf("error! %d\n", ret);
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x44(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    %eax,%ecx
mov    $0x154,%edi
call   1060 <syscall@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    11f2 <main+0xa2>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1203 <main+0xb3>
mov    -0x34(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x154,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1060 <syscall@plt>
test   %eax,%eax
je     11db <main+0x8b>
lea    0xe44(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e7 <main+0x97>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"pid : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"tag : \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [23 x i8] c"successfully inserted\0A\00"
@.str.5 = [11 x i8] c"error! %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = alloca i32
%4 = bitcast [32 x i8]* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = load i32, i32* %1
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @syscall(i32 340, i32 %10, i8* %11, i32 %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %22
19: ; preds = %0
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %17
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"pid : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"tag : \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.5 = [11 x i8] c"error! %d\0A\00"
@str = [22 x i8] c"successfully inserted\00"
define void @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%9 = load i32, i32* %1
%10 = call i32 @strlen(i8* %4)
%11 = call i32 @syscall(i32 340, i32 %9, i8* %4, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %11)
br label %17
17: ; preds = %15, %13
ret void
}