#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ make_patch(int, int, char *);
int /*<<< orphan*/ message_print_diffs(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ remove(char *);
void show_diffs(char *path, int old_rev) {
  int i;
  FILE *res_patch, *current_file;
  FILE *tmp = fopen(".tmp", "w+");
  fclose(tmp);
  make_patch(1, old_rev, path);
  res_patch = fopen(".tmp", "r");
  current_file = fopen(path, "r");
  message_print_diffs(res_patch, current_file, path);
  fclose(res_patch);
  fclose(current_file);
  remove(".tmp");
}


x86 assembly (clang, -O0):
<show_diffs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
call   1050 <make_patch@plt>
lea    0xe69(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1060 <message_print_diffs@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe1b(%rip),%rdi
call   1030 <remove@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_diffs>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xe9c(%rip),%r14
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
mov    %ebp,%esi
mov    %r12,%rdx
call   1050 <make_patch@plt>
lea    0xe77(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %r12,%rdx
call   1060 <message_print_diffs@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <remove@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".tmp\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"r\00"
define void @show_diffs(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %8
%10 = load i32*, i32** %8
%11 = call i32 @fclose(i32* %10)
%12 = load i32, i32* %4
%13 = load i8*, i8** %3
%14 = call i32 @make_patch(i32 1, i32 %12, i8* %13)
%15 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i8*, i8** %3
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %6
%19 = load i32*, i32** %7
%20 = load i8*, i8** %3
%21 = call i32 @message_print_diffs(i32* %18, i32* %19, i8* %20)
%22 = load i32*, i32** %6
%23 = call i32 @fclose(i32* %22)
%24 = load i32*, i32** %7
%25 = call i32 @fclose(i32* %24)
%26 = call i32 @remove(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".tmp\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"r\00"
define void @show_diffs(i8* %0, i32 %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @fclose(i32* %3)
%5 = tail call i32 @make_patch(i32 1, i32 %1, i8* %0)
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @message_print_diffs(i32* %6, i32* %7, i8* %0)
%9 = tail call i32 @fclose(i32* %6)
%10 = tail call i32 @fclose(i32* %7)
%11 = tail call i32 @remove(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret void
}