#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int main() {
  FILE *f = fopen("/usr/lib/libsms.so.0.0.0", "r+");
  if (!f)
    return 1;
  fseek(f, 0xDD78, SEEK_SET);
  unsigned char c = 0x52;
  fwrite(&c, 1, 1, f);
  fseek(f, 0xDD7C, SEEK_SET);
  fwrite(&c, 1, 1, f);
  c = 0xC3;
  fseek(f, 0xDD7F, SEEK_SET);
  fwrite(&c, 1, 1, f);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117d <main+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    1216 <main+0xd6>
mov    -0x10(%rbp),%rdi
mov    0x2e58(%rip),%rax
mov    (%rax),%edx
mov    $0xdd78,%esi
call   1040 <fseek@plt>
movb   $0x52,-0x11(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x11(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fwrite@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
mov    $0xdd7c,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rcx
lea    -0x11(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fwrite@plt>
movb   $0xc3,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2dfa(%rip),%rax
mov    (%rax),%edx
mov    $0xdd7f,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rcx
lea    -0x11(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11c9 <main+0x89>
mov    %rax,%rbx
mov    0x2e7a(%rip),%r14
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xdd78,%esi
call   1050 <fseek@plt>
mov    $0x52,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0xdd7c,%esi
call   1050 <fseek@plt>
mov    $0x52,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0xdd7f,%esi
call   1050 <fseek@plt>
mov    $0xffffffc3,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11ce <main+0x8e>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"/usr/lib/libsms.so.0.0.0\00"
@.str.1 = [3 x i8] c"r+\00"
@SEEK_SET = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %8, label %7
7: ; preds = %0
store i32 1, i32* %1
br label %26
8: ; preds = %0
%9 = load i32*, i32** %2
%10 = load i32, i32* @SEEK_SET
%11 = call i32 @fseek(i32* %9, i32 56696, i32 %10)
store i8 82, i8* %3
%12 = load i32*, i32** %2
%13 = call i32 @fwrite(i8* %3, i32 1, i32 1, i32* %12)
%14 = load i32*, i32** %2
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @fseek(i32* %14, i32 56700, i32 %15)
%17 = load i32*, i32** %2
%18 = call i32 @fwrite(i8* %3, i32 1, i32 1, i32* %17)
store i8 -61, i8* %3
%19 = load i32*, i32** %2
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %19, i32 56703, i32 %20)
%22 = load i32*, i32** %2
%23 = call i32 @fwrite(i8* %3, i32 1, i32 1, i32* %22)
%24 = load i32*, i32** %2
%25 = call i32 @fclose(i32* %24)
store i32 0, i32* %1
br label %26
26: ; preds = %8, %7
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [25 x i8] c"/usr/lib/libsms.so.0.0.0\00"
@.str.1 = [3 x i8] c"r+\00"
@SEEK_SET = global i32 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %14, label %3
3: ; preds = %0
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %1, i32 56696, i32 %4)
%6 = tail call i32 @fputc(i32 82, i32* %1)
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %1, i32 56700, i32 %7)
%9 = tail call i32 @fputc(i32 82, i32* %1)
%10 = load i32, i32* @SEEK_SET
%11 = tail call i32 @fseek(i32* %1, i32 56703, i32 %10)
%12 = tail call i32 @fputc(i32 -61, i32* %1)
%13 = tail call i32 @fclose(i32* %1)
br label %14
14: ; preds = %0, %3
%15 = phi i32 [ 0, %3 ], [ 1, %0 ]
ret i32 %15
}