#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*/ assert(int);
int strtol(char const *, char **, int);
long long strtoll(char const *, char **, int);
unsigned int strtoul(char const *, char **, int);
unsigned long long strtoull(char const *, char **, int);
const char *convert_number(const char *s, int is_signed, size_t size, int base,
                           void *arg) {
  char *endp;
  assert(size == sizeof(int) || size == sizeof(long long));
  if (is_signed) {
    if (size == sizeof(int)) {
      int *p = (int *)arg;
      *p = strtol(s, &endp, base);
    } else {
      long long *p = (long long *)arg;
      *p = strtoll(s, &endp, base);
    }
  } else {
    if (size == sizeof(unsigned int)) {
      unsigned int *p = (unsigned int *)arg;
      *p = strtoul(s, &endp, base);
    } else {
      unsigned long long *p = (unsigned long long *)arg;
      *p = strtoull(s, &endp, base);
    }
  }
  return endp;
}


x86 assembly (clang, -O0):
<convert_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    $0x1,%al
cmpq   $0x4,-0x18(%rbp)
mov    %al,-0x51(%rbp)
je     1185 <convert_number+0x35>
cmpq   $0x8,-0x18(%rbp)
sete   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
je     11f3 <convert_number+0xa3>
cmpq   $0x4,-0x18(%rbp)
jne    11cc <convert_number+0x7c>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   1060 <strtol@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ee <convert_number+0x9e>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   1040 <strtoll@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
jmp    124a <convert_number+0xfa>
cmpq   $0x4,-0x18(%rbp)
jne    1223 <convert_number+0xd3>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   1070 <strtoul@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
jmp    1245 <convert_number+0xf5>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   1030 <strtoull@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
mov    %rcx,(%rax)
jmp    124a <convert_number+0xfa>
mov    -0x30(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_number>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rdx,%rbp
mov    %esi,%ebx
mov    %rdi,%r12
lea    -0x4(%rdx),%rax
xor    %edi,%edi
test   $0xfffffffffffffffb,%rax
sete   %dil
call   1050 <assert@plt>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
mov    %r15d,%edx
test   %ebx,%ebx
je     119e <convert_number+0x4e>
cmp    $0x4,%rbp
jne    11ae <convert_number+0x5e>
call   1060 <strtol@plt>
mov    %eax,(%r14)
jmp    11bd <convert_number+0x6d>
cmp    $0x4,%rbp
jne    11b5 <convert_number+0x65>
call   1070 <strtoul@plt>
mov    %eax,(%r14)
jmp    11bd <convert_number+0x6d>
call   1040 <strtoll@plt>
jmp    11ba <convert_number+0x6a>
call   1030 <strtoull@plt>
mov    %rax,(%r14)
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @convert_number(i8* %0, i32 %1, i64 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i64*
%14 = alloca i32*
%15 = alloca i64*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i64 %2, i64* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%16 = load i64, i64* %8
%17 = icmp eq i64 %16, 4
br i1 %17, label %21, label %18
18: ; preds = %5
%19 = load i64, i64* %8
%20 = icmp eq i64 %19, 8
br label %21
21: ; preds = %18, %5
%22 = phi i1 [ true, %5 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %45
27: ; preds = %21
%28 = load i64, i64* %8
%29 = icmp eq i64 %28, 4
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i8*, i8** %10
%32 = bitcast i8* %31 to i32*
store i32* %32, i32** %12
%33 = load i8*, i8** %6
%34 = load i32, i32* %9
%35 = call i32 @strtol(i8* %33, i8** %11, i32 %34)
%36 = load i32*, i32** %12
store i32 %35, i32* %36
br label %44
37: ; preds = %27
%38 = load i8*, i8** %10
%39 = bitcast i8* %38 to i64*
store i64* %39, i64** %13
%40 = load i8*, i8** %6
%41 = load i32, i32* %9
%42 = call i64 @strtoll(i8* %40, i8** %11, i32 %41)
%43 = load i64*, i64** %13
store i64 %42, i64* %43
br label %44
44: ; preds = %37, %30
br label %63
45: ; preds = %21
%46 = load i64, i64* %8
%47 = icmp eq i64 %46, 4
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i8*, i8** %10
%50 = bitcast i8* %49 to i32*
store i32* %50, i32** %14
%51 = load i8*, i8** %6
%52 = load i32, i32* %9
%53 = call i32 @strtoul(i8* %51, i8** %11, i32 %52)
%54 = load i32*, i32** %14
store i32 %53, i32* %54
br label %62
55: ; preds = %45
%56 = load i8*, i8** %10
%57 = bitcast i8* %56 to i64*
store i64* %57, i64** %15
%58 = load i8*, i8** %6
%59 = load i32, i32* %9
%60 = call i64 @strtoull(i8* %58, i8** %11, i32 %59)
%61 = load i64*, i64** %15
store i64 %60, i64* %61
br label %62
62: ; preds = %55, %48
br label %63
63: ; preds = %62, %44
%64 = load i8*, i8** %11
ret i8* %64
}

LLVM IR (-O2):
define i8* @convert_number(i8* %0, i32 %1, i64 %2, i32 %3, i8* nocapture writeonly %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
%8 = icmp eq i64 %2, 4
%9 = icmp eq i64 %2, 8
%10 = or i1 %8, %9
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp eq i32 %1, 0
br i1 %13, label %21, label %14
14: ; preds = %5
br i1 %8, label %15, label %18
15: ; preds = %14
%16 = bitcast i8* %4 to i32*
%17 = call i32 @strtol(i8* %0, i8** %6, i32 %3)
store i32 %17, i32* %16
br label %28
18: ; preds = %14
%19 = bitcast i8* %4 to i64*
%20 = call i64 @strtoll(i8* %0, i8** %6, i32 %3)
store i64 %20, i64* %19
br label %28
21: ; preds = %5
br i1 %8, label %22, label %25
22: ; preds = %21
%23 = bitcast i8* %4 to i32*
%24 = call i32 @strtoul(i8* %0, i8** %6, i32 %3)
store i32 %24, i32* %23
br label %28
25: ; preds = %21
%26 = bitcast i8* %4 to i64*
%27 = call i64 @strtoull(i8* %0, i8** %6, i32 %3)
store i64 %27, i64* %26
br label %28
28: ; preds = %22, %25, %15, %18
%29 = load i8*, i8** %6
ret i8* %29
}