#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*/ err_exit(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ errno;
scalar_t__ realloc(int *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int *resize_list(int *list, int *current_size) {
  int *new_list;
  new_list = (int *)realloc(list, (sizeof(int) * (*current_size) * 2));
  if (new_list == NULL) {
    err_exit("Error on realloc: %s, %d", strerror(errno), 106);
  }
  (*current_size) *= 2;
  return new_list;
}


x86 assembly (clang, -O0):
<resize_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
shl    $0x1,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118a <resize_list+0x5a>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%esi
lea    0xe80(%rip),%rdi
mov    $0x6a,%edx
call   1030 <err_exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
shl    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resize_list>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rsi),%esi
shl    $0x3,%esi
call   1040 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116a <resize_list+0x3a>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xea2(%rip),%rdi
mov    %eax,%esi
mov    $0x6a,%edx
call   1030 <err_exit@plt>
shll   (%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Error on realloc: %s, %d\00"
@errno = global i32 0
define i32* @resize_list(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = sext i32 %8 to i64
%10 = mul i64 4, %9
%11 = mul i64 %10, 2
%12 = trunc i64 %11 to i32
%13 = call i64 @realloc(i32* %6, i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %5
%15 = load i32*, i32** %5
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 @err_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %19, i32 106)
br label %21
21: ; preds = %17, %2
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = mul nsw i32 %23, 2
store i32 %24, i32* %22
%25 = load i32*, i32** %5
ret i32* %25
}

LLVM IR (-O2):
@.str = [25 x i8] c"Error on realloc: %s, %d\00"
@errno = global i32 0
define i32* @resize_list(i32* %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = shl i32 %3, 3
%5 = tail call i64 @realloc(i32* %0, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @errno
%9 = tail call i32 @strerror(i32 %8)
%10 = tail call i32 @err_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %9, i32 106)
br label %11
11: ; preds = %7, %2
%12 = inttoptr i64 %5 to i32*
%13 = load i32, i32* %1
%14 = shl nsw i32 %13, 1
store i32 %14, i32* %1
ret i32* %12
}