#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 long time_t;
typedef long int8_t;
typedef long int32_t;
typedef long int16_t;

/* Variables and functions */
scalar_t__ strcmp(char const *, char *);
void ser_write_signed(void *ptr, const char *type, const signed long svalue) {
  if (strcmp(type, "short") == 0)
    *(short *)ptr = svalue;
  else if (strcmp(type, "int") == 0)
    *(int *)ptr = svalue;
  else if (strcmp(type, "long") == 0)
    *(long *)ptr = svalue;
  else if (strcmp(type, "int8_t") == 0)
    *(int8_t *)ptr = svalue;
  else if (strcmp(type, "int16_t") == 0)
    *(int16_t *)ptr = svalue;
  else if (strcmp(type, "int32_t") == 0)
    *(int32_t *)ptr = svalue;
  else if (strcmp(type, "time_t") == 0)
    *(time_t *)ptr = svalue;
  return;
}


x86 assembly (clang, -O0):
<ser_write_signed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1151 <ser_write_signed+0x41>
mov    -0x18(%rbp),%rax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
jmp    1267 <ser_write_signed+0x157>
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    117c <ser_write_signed+0x6c>
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1262 <ser_write_signed+0x152>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a6 <ser_write_signed+0x96>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    125d <ser_write_signed+0x14d>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d0 <ser_write_signed+0xc0>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1258 <ser_write_signed+0x148>
mov    -0x10(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11fa <ser_write_signed+0xea>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1253 <ser_write_signed+0x143>
mov    -0x10(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1224 <ser_write_signed+0x114>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    124e <ser_write_signed+0x13e>
mov    -0x10(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1249 <ser_write_signed+0x139>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    124e <ser_write_signed+0x13e>
jmp    1253 <ser_write_signed+0x143>
jmp    1258 <ser_write_signed+0x148>
jmp    125d <ser_write_signed+0x14d>
jmp    1262 <ser_write_signed+0x152>
jmp    1267 <ser_write_signed+0x157>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ser_write_signed>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xedb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11af <ser_write_signed+0x9f>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b5 <ser_write_signed+0xa5>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11aa <ser_write_signed+0x9a>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11aa <ser_write_signed+0x9a>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11aa <ser_write_signed+0x9a>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11aa <ser_write_signed+0x9a>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11b8 <ser_write_signed+0xa8>
mov    %r14,(%r15)
jmp    11b8 <ser_write_signed+0xa8>
mov    %r14w,(%r15)
jmp    11b8 <ser_write_signed+0xa8>
mov    %r14d,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"short\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [5 x i8] c"long\00"
@.str.3 = [7 x i8] c"int8_t\00"
@.str.4 = [8 x i8] c"int16_t\00"
@.str.5 = [8 x i8] c"int32_t\00"
@.str.6 = [7 x i8] c"time_t\00"
define void @ser_write_signed(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %5
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load i64, i64* %6
%12 = trunc i64 %11 to i16
%13 = load i8*, i8** %4
%14 = bitcast i8* %13 to i16*
store i16 %12, i16* %14
br label %70
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i64, i64* %6
%21 = trunc i64 %20 to i32
%22 = load i8*, i8** %4
%23 = bitcast i8* %22 to i32*
store i32 %21, i32* %23
br label %69
24: ; preds = %15
%25 = load i8*, i8** %5
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i64, i64* %6
%30 = load i8*, i8** %4
%31 = bitcast i8* %30 to i64*
store i64 %29, i64* %31
br label %68
32: ; preds = %24
%33 = load i8*, i8** %5
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i64, i64* %6
%38 = load i8*, i8** %4
%39 = bitcast i8* %38 to i64*
store i64 %37, i64* %39
br label %67
40: ; preds = %32
%41 = load i8*, i8** %5
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i64, i64* %6
%46 = load i8*, i8** %4
%47 = bitcast i8* %46 to i64*
store i64 %45, i64* %47
br label %66
48: ; preds = %40
%49 = load i8*, i8** %5
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i64, i64* %6
%54 = load i8*, i8** %4
%55 = bitcast i8* %54 to i64*
store i64 %53, i64* %55
br label %65
56: ; preds = %48
%57 = load i8*, i8** %5
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i64, i64* %6
%62 = load i8*, i8** %4
%63 = bitcast i8* %62 to i64*
store i64 %61, i64* %63
br label %64
64: ; preds = %60, %56
br label %65
65: ; preds = %64, %52
br label %66
66: ; preds = %65, %44
br label %67
67: ; preds = %66, %36
br label %68
68: ; preds = %67, %28
br label %69
69: ; preds = %68, %19
br label %70
70: ; preds = %69, %10
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"short\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [5 x i8] c"long\00"
@.str.3 = [7 x i8] c"int8_t\00"
@.str.4 = [8 x i8] c"int16_t\00"
@.str.5 = [8 x i8] c"int32_t\00"
@.str.6 = [7 x i8] c"time_t\00"
define void @ser_write_signed(i8* nocapture writeonly %0, i8* %1, i64 %2) {
%4 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = trunc i64 %2 to i16
%8 = bitcast i8* %0 to i16*
store i16 %7, i16* %8
br label %40
9: ; preds = %3
%10 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = trunc i64 %2 to i32
%14 = bitcast i8* %0 to i32*
store i32 %13, i32* %14
br label %40
15: ; preds = %9
%16 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = bitcast i8* %0 to i64*
store i64 %2, i64* %19
br label %40
20: ; preds = %15
%21 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = bitcast i8* %0 to i64*
store i64 %2, i64* %24
br label %40
25: ; preds = %20
%26 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = bitcast i8* %0 to i64*
store i64 %2, i64* %29
br label %40
30: ; preds = %25
%31 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = bitcast i8* %0 to i64*
store i64 %2, i64* %34
br label %40
35: ; preds = %30
%36 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = bitcast i8* %0 to i64*
store i64 %2, i64* %39
br label %40
40: ; preds = %12, %23, %33, %38, %35, %28, %18, %6
ret void
}