#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 */
struct boot_params {
  int /*<<< orphan*/ *_pad9;
  int /*<<< orphan*/ *_pad8;
  int /*<<< orphan*/ *eddbuf;
  int /*<<< orphan*/ *_pad7;
  int /*<<< orphan*/ *edd_mbr_sig_buffer;
  int /*<<< orphan*/ *_pad5;
  int /*<<< orphan*/ hdr;
  int /*<<< orphan*/ kbd_status;
  int /*<<< orphan*/ ext_ramdisk_image;
  int /*<<< orphan*/ efi_info;
  scalar_t__ sentinel;
};

/* Variables and functions */
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
void sanitize_boot_params(struct boot_params *boot_params) {
  if (boot_params->sentinel) {
    memset(&boot_params->ext_ramdisk_image, 0,
           (char *)&boot_params->efi_info -
               (char *)&boot_params->ext_ramdisk_image);
    memset(&boot_params->kbd_status, 0, sizeof(boot_params->kbd_status));
    memset(&boot_params->_pad5[0], 0,
           (char *)&boot_params->hdr - (char *)&boot_params->_pad5[0]);
    memset(&boot_params->_pad7[0], 0,
           (char *)&boot_params->edd_mbr_sig_buffer[0] -
               (char *)&boot_params->_pad7[0]);
    memset(&boot_params->_pad8[0], 0,
           (char *)&boot_params->eddbuf[0] - (char *)&boot_params->_pad8[0]);
    memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9));
  }
}


x86 assembly (clang, -O0):
<sanitize_boot_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x40(%rax)
je     11e2 <sanitize_boot_params+0xd2>
mov    -0x8(%rbp),%rdi
add    $0x38,%rdi
mov    -0x8(%rbp),%rax
add    $0x3c,%rax
mov    -0x8(%rbp),%rcx
add    $0x38,%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
add    $0x34,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%rdi
mov    -0x8(%rbp),%rax
add    $0x30,%rax
mov    -0x8(%rbp),%rcx
mov    0x28(%rcx),%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x18(%rcx),%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sanitize_boot_params>:
push   %rbx
cmpq   $0x0,0x40(%rdi)
je     117d <sanitize_boot_params+0x6d>
mov    %rdi,%rbx
add    $0x38,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    0x34(%rbx),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    0x28(%rbx),%rdi
mov    %ebx,%edx
sub    %edi,%edx
add    $0x30,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x18(%rbx),%rdi
mov    0x20(%rbx),%edx
sub    %edi,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%edx
sub    %edi,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    (%rbx),%rdi
xor    %esi,%esi
mov    $0x8,%edx
pop    %rbx
jmp    1030 <memset@plt>
pop    %rbx
ret

LLVM IR (-O0):
%struct.boot_params = type { i32*, i32*, i32*, i32*, i32*, i32*, i32, i32, i32, i32, i64 }
define void @sanitize_boot_params(%struct.boot_params* %0) {
%2 = alloca %struct.boot_params*
store %struct.boot_params* %0, %struct.boot_params** %2
%3 = load %struct.boot_params*, %struct.boot_params** %2
%4 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %3, i32 0, i32 10
%5 = load i64, i64* %4
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %84
7: ; preds = %1
%8 = load %struct.boot_params*, %struct.boot_params** %2
%9 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %8, i32 0, i32 8
%10 = load %struct.boot_params*, %struct.boot_params** %2
%11 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %10, i32 0, i32 9
%12 = bitcast i32* %11 to i8*
%13 = load %struct.boot_params*, %struct.boot_params** %2
%14 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %13, i32 0, i32 8
%15 = bitcast i32* %14 to i8*
%16 = ptrtoint i8* %12 to i64
%17 = ptrtoint i8* %15 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
%20 = call i32 @memset(i32* %9, i32 0, i32 %19)
%21 = load %struct.boot_params*, %struct.boot_params** %2
%22 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %21, i32 0, i32 7
%23 = call i32 @memset(i32* %22, i32 0, i32 4)
%24 = load %struct.boot_params*, %struct.boot_params** %2
%25 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %24, i32 0, i32 5
%26 = load i32*, i32** %25
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load %struct.boot_params*, %struct.boot_params** %2
%29 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %28, i32 0, i32 6
%30 = bitcast i32* %29 to i8*
%31 = load %struct.boot_params*, %struct.boot_params** %2
%32 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %31, i32 0, i32 5
%33 = load i32*, i32** %32
%34 = getelementptr inbounds i32, i32* %33, i64 0
%35 = bitcast i32* %34 to i8*
%36 = ptrtoint i8* %30 to i64
%37 = ptrtoint i8* %35 to i64
%38 = sub i64 %36, %37
%39 = trunc i64 %38 to i32
%40 = call i32 @memset(i32* %27, i32 0, i32 %39)
%41 = load %struct.boot_params*, %struct.boot_params** %2
%42 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %41, i32 0, i32 3
%43 = load i32*, i32** %42
%44 = getelementptr inbounds i32, i32* %43, i64 0
%45 = load %struct.boot_params*, %struct.boot_params** %2
%46 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %45, i32 0, i32 4
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 0
%49 = bitcast i32* %48 to i8*
%50 = load %struct.boot_params*, %struct.boot_params** %2
%51 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %50, i32 0, i32 3
%52 = load i32*, i32** %51
%53 = getelementptr inbounds i32, i32* %52, i64 0
%54 = bitcast i32* %53 to i8*
%55 = ptrtoint i8* %49 to i64
%56 = ptrtoint i8* %54 to i64
%57 = sub i64 %55, %56
%58 = trunc i64 %57 to i32
%59 = call i32 @memset(i32* %44, i32 0, i32 %58)
%60 = load %struct.boot_params*, %struct.boot_params** %2
%61 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %60, i32 0, i32 1
%62 = load i32*, i32** %61
%63 = getelementptr inbounds i32, i32* %62, i64 0
%64 = load %struct.boot_params*, %struct.boot_params** %2
%65 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %64, i32 0, i32 2
%66 = load i32*, i32** %65
%67 = getelementptr inbounds i32, i32* %66, i64 0
%68 = bitcast i32* %67 to i8*
%69 = load %struct.boot_params*, %struct.boot_params** %2
%70 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %69, i32 0, i32 1
%71 = load i32*, i32** %70
%72 = getelementptr inbounds i32, i32* %71, i64 0
%73 = bitcast i32* %72 to i8*
%74 = ptrtoint i8* %68 to i64
%75 = ptrtoint i8* %73 to i64
%76 = sub i64 %74, %75
%77 = trunc i64 %76 to i32
%78 = call i32 @memset(i32* %63, i32 0, i32 %77)
%79 = load %struct.boot_params*, %struct.boot_params** %2
%80 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %79, i32 0, i32 0
%81 = load i32*, i32** %80
%82 = getelementptr inbounds i32, i32* %81, i64 0
%83 = call i32 @memset(i32* %82, i32 0, i32 8)
br label %84
84: ; preds = %7, %1
ret void
}

LLVM IR (-O2):
%struct.boot_params = type { i32*, i32*, i32*, i32*, i32*, i32*, i32, i32, i32, i32, i64 }
define void @sanitize_boot_params(%struct.boot_params* %0) {
%2 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 10
%3 = load i64, i64* %2
%4 = icmp eq i64 %3, 0
br i1 %4, label %41, label %5
5: ; preds = %1
%6 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 8
%7 = tail call i32 @memset(i32* %6, i32 0, i32 4)
%8 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 7
%9 = tail call i32 @memset(i32* %8, i32 0, i32 4)
%10 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 5
%11 = load i32*, i32** %10
%12 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 6
%13 = ptrtoint i32* %12 to i64
%14 = ptrtoint i32* %11 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
%17 = tail call i32 @memset(i32* %11, i32 0, i32 %16)
%18 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 3
%19 = load i32*, i32** %18
%20 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 4
%21 = bitcast i32** %20 to i8**
%22 = load i8*, i8** %21
%23 = ptrtoint i8* %22 to i64
%24 = ptrtoint i32* %19 to i64
%25 = sub i64 %23, %24
%26 = trunc i64 %25 to i32
%27 = tail call i32 @memset(i32* %19, i32 0, i32 %26)
%28 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 1
%29 = load i32*, i32** %28
%30 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 2
%31 = bitcast i32** %30 to i8**
%32 = load i8*, i8** %31
%33 = ptrtoint i8* %32 to i64
%34 = ptrtoint i32* %29 to i64
%35 = sub i64 %33, %34
%36 = trunc i64 %35 to i32
%37 = tail call i32 @memset(i32* %29, i32 0, i32 %36)
%38 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %0, i64 0, i32 0
%39 = load i32*, i32** %38
%40 = tail call i32 @memset(i32* %39, i32 0, i32 8)
br label %41
41: ; preds = %5, %1
ret void
}