#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int offset;
  FILE *fp;
  char buff;
  if (argc != 3) {
    printf("usage:<filename> <Offset value>");
    return 1;
  } else {
    if ((fp = fopen(argv[1], "rb+")) == NULL) {
      printf("file not found");
      return 1;
    } else {
      offset = atoi(argv[2]);
      fseek(fp, offset, 0);
      buff = fgetc(fp);
      buff = buff + 1;
      fseek(fp, offset, 0);
      fputc(buff, fp);
    }
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a8 <main+0x38>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1243 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11e2 <main+0x72>
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1243 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
add    $0x1,%eax
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    11e3 <main+0x73>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe96(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ec <main+0x7c>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,%r15d
add    $0x1,%r15b
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1070 <fseek@plt>
movsbl %r15b,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    11fd <main+0x8d>
lea    0xe16(%rip),%rdi
jmp    11f3 <main+0x83>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"usage:<filename> <Offset value>\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [15 x i8] c"file not found\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %45
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %45
21: ; preds = %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
%26 = load i32*, i32** %7
%27 = load i32, i32* %6
%28 = call i32 @fseek(i32* %26, i32 %27, i32 0)
%29 = load i32*, i32** %7
%30 = call signext i8 @fgetc(i32* %29)
store i8 %30, i8* %8
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = add nsw i32 %32, 1
%34 = trunc i32 %33 to i8
store i8 %34, i8* %8
%35 = load i32*, i32** %7
%36 = load i32, i32* %6
%37 = call i32 @fseek(i32* %35, i32 %36, i32 0)
%38 = load i8, i8* %8
%39 = load i32*, i32** %7
%40 = call i32 @fputc(i8 signext %38, i32* %39)
br label %41
41: ; preds = %21
%42 = load i32*, i32** %7
%43 = call i32 @fclose(i32* %42)
br label %44
44: ; preds = %41
store i32 0, i32* %3
br label %45
45: ; preds = %44, %19, %11
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [32 x i8] c"usage:<filename> <Offset value>\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [15 x i8] c"file not found\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %23
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %23
13: ; preds = %6
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = tail call i32 @fseek(i32* %9, i32 %16, i32 0)
%18 = tail call signext i8 @fgetc(i32* %9)
%19 = add i8 %18, 1
%20 = tail call i32 @fseek(i32* %9, i32 %16, i32 0)
%21 = tail call i32 @fputc(i8 signext %19, i32* %9)
%22 = tail call i32 @fclose(i32* %9)
br label %23
23: ; preds = %13, %11, %4
%24 = phi i32 [ 1, %4 ], [ 1, %11 ], [ 0, %13 ]
ret i32 %24
}