#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*/ atoi(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
unsigned int replace_byte(unsigned int, int /*<<< orphan*/, unsigned int);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  unsigned int n = strtoul(argv[1], NULL, 16);
  n = replace_byte(n, atoi(argv[2]), strtoul(argv[3], NULL, 16));
  printf("output:0x%08x\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    %eax,%edx
call   1060 <replace_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1060 <replace_byte@plt>
lea    0xe78(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"output:0x%08x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @strtoul(i8* %9, i32* null, i32 16)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 3
%18 = load i8*, i8** %17
%19 = call i32 @strtoul(i8* %18, i32* null, i32 16)
%20 = call i32 @replace_byte(i32 %11, i32 %15, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"output:0x%08x\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @strtoul(i8* nocapture %4, i32* null, i32 16)
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call i32 @strtoul(i8* nocapture %10, i32* null, i32 16)
%12 = tail call i32 @replace_byte(i32 %5, i32 %8, i32 %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12)
ret i32 0
}