#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*/ get_payload_info(char *, int *, int *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
void update_payload_info(char *bzimage, int new_size) {
  int offset, size;
  get_payload_info(bzimage, &offset, &size);
  *((int *)&bzimage[0x24c]) = new_size;
  if (new_size < size)
    memset(bzimage + offset + new_size, 0, size - new_size);
}


x86 assembly (clang, -O0):
<update_payload_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <get_payload_info@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24c(%rax)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1178 <update_payload_info+0x58>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x14(%rbp),%edx
sub    -0xc(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_payload_info>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <get_payload_info@plt>
mov    %ebp,0x24c(%rbx)
mov    (%rsp),%edx
sub    %ebp,%edx
jle    1157 <update_payload_info+0x37>
movslq 0x4(%rsp),%rax
add    %rax,%rbx
movslq %ebp,%rdi
add    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @update_payload_info(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @get_payload_info(i8* %7, i32* %5, i32* %6)
%9 = load i32, i32* %4
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 588
%12 = bitcast i8* %11 to i32*
store i32 %9, i32* %12
%13 = load i32, i32* %4
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i32, i32* %6
%25 = load i32, i32* %4
%26 = sub nsw i32 %24, %25
%27 = call i32 @memset(i8* %23, i32 0, i32 %26)
br label %28
28: ; preds = %16, %2
ret void
}

LLVM IR (-O2):
define void @update_payload_info(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @get_payload_info(i8* %0, i32* %3, i32* %4)
%8 = getelementptr inbounds i8, i8* %0, i64 588
%9 = bitcast i8* %8 to i32*
store i32 %1, i32* %9
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, %1
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = sext i32 %1 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = sub nsw i32 %10, %1
%19 = call i32 @memset(i8* %17, i32 0, i32 %18)
br label %20
20: ; preds = %12, %2
ret void
}