#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*/ kbd_status;
  int /*<<< orphan*/ hdr;
  int /*<<< orphan*/ olpc_ofw_header;
  int /*<<< orphan*/ alt_mem_k;
  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->olpc_ofw_header, 0,
           (char *)&boot_params->alt_mem_k -
               (char *)&boot_params->olpc_ofw_header);
    memset(&boot_params->kbd_status, 0,
           (char *)&boot_params->hdr - (char *)&boot_params->kbd_status);
    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,0x38(%rax)
je     11ce <sanitize_boot_params+0xbe>
mov    -0x8(%rbp),%rdi
add    $0x30,%rdi
mov    -0x8(%rbp),%rax
add    $0x34,%rax
mov    -0x8(%rbp),%rcx
add    $0x30,%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
add    $0x28,%rdi
mov    -0x8(%rbp),%rax
add    $0x2c,%rax
mov    -0x8(%rbp),%rcx
add    $0x28,%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,0x38(%rdi)
je     116b <sanitize_boot_params+0x5b>
mov    %rdi,%rbx
add    $0x30,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    0x28(%rbx),%rdi
xor    %esi,%esi
mov    $0x4,%edx
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, 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 9
%5 = load i64, i64* %4
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %77
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 7
%10 = load %struct.boot_params*, %struct.boot_params** %2
%11 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %10, i32 0, i32 8
%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 7
%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 5
%23 = load %struct.boot_params*, %struct.boot_params** %2
%24 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %23, i32 0, i32 6
%25 = bitcast i32* %24 to i8*
%26 = load %struct.boot_params*, %struct.boot_params** %2
%27 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %26, i32 0, i32 5
%28 = bitcast i32* %27 to i8*
%29 = ptrtoint i8* %25 to i64
%30 = ptrtoint i8* %28 to i64
%31 = sub i64 %29, %30
%32 = trunc i64 %31 to i32
%33 = call i32 @memset(i32* %22, i32 0, i32 %32)
%34 = load %struct.boot_params*, %struct.boot_params** %2
%35 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %34, i32 0, i32 3
%36 = load i32*, i32** %35
%37 = getelementptr inbounds i32, i32* %36, i64 0
%38 = load %struct.boot_params*, %struct.boot_params** %2
%39 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %38, i32 0, i32 4
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 0
%42 = bitcast i32* %41 to i8*
%43 = load %struct.boot_params*, %struct.boot_params** %2
%44 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %43, i32 0, i32 3
%45 = load i32*, i32** %44
%46 = getelementptr inbounds i32, i32* %45, i64 0
%47 = bitcast i32* %46 to i8*
%48 = ptrtoint i8* %42 to i64
%49 = ptrtoint i8* %47 to i64
%50 = sub i64 %48, %49
%51 = trunc i64 %50 to i32
%52 = call i32 @memset(i32* %37, i32 0, i32 %51)
%53 = load %struct.boot_params*, %struct.boot_params** %2
%54 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %53, i32 0, i32 1
%55 = load i32*, i32** %54
%56 = getelementptr inbounds i32, i32* %55, i64 0
%57 = load %struct.boot_params*, %struct.boot_params** %2
%58 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %57, i32 0, i32 2
%59 = load i32*, i32** %58
%60 = getelementptr inbounds i32, i32* %59, i64 0
%61 = bitcast i32* %60 to i8*
%62 = load %struct.boot_params*, %struct.boot_params** %2
%63 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %62, i32 0, i32 1
%64 = load i32*, i32** %63
%65 = getelementptr inbounds i32, i32* %64, i64 0
%66 = bitcast i32* %65 to i8*
%67 = ptrtoint i8* %61 to i64
%68 = ptrtoint i8* %66 to i64
%69 = sub i64 %67, %68
%70 = trunc i64 %69 to i32
%71 = call i32 @memset(i32* %56, i32 0, i32 %70)
%72 = load %struct.boot_params*, %struct.boot_params** %2
%73 = getelementptr inbounds %struct.boot_params, %struct.boot_params* %72, i32 0, i32 0
%74 = load i32*, i32** %73
%75 = getelementptr inbounds i32, i32* %74, i64 0
%76 = call i32 @memset(i32* %75, i32 0, i32 8)
br label %77
77: ; preds = %7, %1
ret void
}

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