#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int make_changes(unsigned char *buf, int offset_to_apply, int bytes_to_apply,
                 size_t s, int *check_tweak) {
  if (offset_to_apply <= s) {
    uint8_t value = buf[offset_to_apply];
    if (value == bytes_to_apply) {
      *check_tweak = *check_tweak + 1;
    }
    buf[offset_to_apply] = bytes_to_apply;
    value = buf[offset_to_apply];
    return 0;
  } else {
    printf("offset too big?????\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<make_changes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x20(%rbp),%rax
ja     118d <make_changes+0x7d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1162 <make_changes+0x52>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x4(%rbp)
jmp    11a0 <make_changes+0x90>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_changes>:
push   %rax
movslq %esi,%rax
cmp    %rcx,%rax
jbe    112c <make_changes+0x1c>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
movzbl (%rdi,%rax,1),%ecx
cmp    %edx,%ecx
jne    1138 <make_changes+0x28>
addl   $0x1,(%r8)
mov    %dl,(%rdi,%rax,1)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"offset too big?????\0A\00"
define i32 @make_changes(i8* %0, i32 %1, i32 %2, i64 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i64 %3, i64* %10
store i32* %4, i32** %11
%13 = load i32, i32* %8
%14 = sext i32 %13 to i64
%15 = load i64, i64* %10
%16 = icmp ule i64 %14, %15
br i1 %16, label %17, label %45
17: ; preds = %5
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
store i32 %23, i32* %12
%24 = load i32, i32* %12
%25 = load i32, i32* %9
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %32
27: ; preds = %17
%28 = load i32*, i32** %11
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
%31 = load i32*, i32** %11
store i32 %30, i32* %31
br label %32
32: ; preds = %27, %17
%33 = load i32, i32* %9
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %7
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
%39 = load i8*, i8** %7
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
store i32 %44, i32* %12
store i32 0, i32* %6
br label %47
45: ; preds = %5
%46 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %47
47: ; preds = %45, %32
%48 = load i32, i32* %6
ret i32 %48
}

LLVM IR (-O2):
@str = [20 x i8] c"offset too big?????\00"
define i32 @make_changes(i8* nocapture %0, i32 %1, i32 %2, i64 %3, i32* nocapture %4) {
%6 = sext i32 %1 to i64
%7 = icmp ugt i64 %6, %3
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %0, i64 %6
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, %2
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %16
16: ; preds = %13, %8
%17 = trunc i32 %2 to i8
store i8 %17, i8* %9
br label %20
18: ; preds = %5
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ 0, %16 ], [ 1, %18 ]
ret i32 %21
}