#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*/ print_mem(unsigned long, unsigned long);
int /*<<< orphan*/ puts(char *);
scalar_t__ strtol(char *, void *, int /*<<< orphan*/);
int poke(int argc, char **argv) {
  unsigned long address, value;
  if (argc < 3) {
    puts("Usage: poke addr value");
    return -1;
  }
  address = (unsigned long)strtol(argv[1], ((void *)0L), 0);
  value = (unsigned long)strtol(argv[2], ((void *)0L), 0);
  *((volatile unsigned long *)address) = value;
  value = *((volatile unsigned long *)address);
  print_mem(address, value);
  return 0;
}


x86 assembly (clang, -O0):
<poke>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1161 <poke+0x31>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b9 <poke+0x89>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <print_mem@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poke>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jg     114e <poke+0x1e>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
jmp    117f <poke+0x4f>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,%rbx
mov    0x10(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,(%rbx)
mov    (%rbx),%rsi
mov    %rbx,%rdi
call   1050 <print_mem@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: poke addr value\00"
define i32 @poke(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %30
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strtol(i8* %15, i8* null, i32 0)
store i64 %16, i64* %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i64 @strtol(i8* %19, i8* null, i32 0)
store i64 %20, i64* %7
%21 = load i64, i64* %7
%22 = load i64, i64* %6
%23 = inttoptr i64 %22 to i64*
store volatile i64 %21, i64* %23
%24 = load i64, i64* %6
%25 = inttoptr i64 %24 to i64*
%26 = load volatile i64, i64* %25
store i64 %26, i64* %7
%27 = load i64, i64* %6
%28 = load i64, i64* %7
%29 = call i32 @print_mem(i64 %27, i64 %28)
store i32 0, i32* %3
br label %30
30: ; preds = %12, %10
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: poke addr value\00"
define i32 @poke(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strtol(i8* nocapture %8, i8* null, i32 0)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i64 @strtol(i8* nocapture %11, i8* null, i32 0)
%13 = inttoptr i64 %9 to i64*
store volatile i64 %12, i64* %13
%14 = load volatile i64, i64* %13
%15 = tail call i32 @print_mem(i64 %9, i64 %14)
br label %16
16: ; preds = %6, %4
%17 = phi i32 [ -1, %4 ], [ 0, %6 ]
ret i32 %17
}