#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 RIFF_FindSubChunk(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/);
void *RIFF_ReadInChunk(int /*<<< orphan*/ *, int, int *);
int /*<<< orphan*/ printf(char *, char *);
void *RIFF_FindReadInChunk(FILE *fd, int ofs, int id, int *size) {
  int ch_ofs;
  void *p;
  ch_ofs = RIFF_FindSubChunk(fd, ofs, id, 0);
  if (ch_ofs < 0) {
    printf("Missing %04s\n", (char *)(&id));
    return (NULL);
  }
  p = RIFF_ReadInChunk(fd, ch_ofs, size);
  return (p);
}


x86 assembly (clang, -O0):
<RIFF_FindReadInChunk>:
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    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
call   1040 <RIFF_FindSubChunk@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1181 <RIFF_FindReadInChunk+0x51>
lea    -0x18(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    119d <RIFF_FindReadInChunk+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1050 <RIFF_ReadInChunk@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RIFF_FindReadInChunk>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdi,%rbx
mov    %edx,0x4(%rsp)
xor    %ecx,%ecx
call   1040 <RIFF_FindSubChunk@plt>
test   %eax,%eax
js     115d <RIFF_FindReadInChunk+0x2d>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <RIFF_ReadInChunk@plt>
lea    0xe9c(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Missing %04s\0A\00"
define i8* @RIFF_FindReadInChunk(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%12 = load i32*, i32** %6
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = call i32 @RIFF_FindSubChunk(i32* %12, i32 %13, i32 %14, i32 0)
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = bitcast i32* %8 to i8*
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %19)
store i8* null, i8** %5
br label %27
21: ; preds = %4
%22 = load i32*, i32** %6
%23 = load i32, i32* %10
%24 = load i32*, i32** %9
%25 = call i8* @RIFF_ReadInChunk(i32* %22, i32 %23, i32* %24)
store i8* %25, i8** %11
%26 = load i8*, i8** %11
store i8* %26, i8** %5
br label %27
27: ; preds = %21, %18
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
@.str = [14 x i8] c"Missing %04s\0A\00"
define i8* @RIFF_FindReadInChunk(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
store i32 %2, i32* %5
%6 = tail call i32 @RIFF_FindSubChunk(i32* %0, i32 %1, i32 %2, i32 0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = bitcast i32* %5 to i8*
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %13
11: ; preds = %4
%12 = tail call i8* @RIFF_ReadInChunk(i32* %0, i32 %6, i32* %3)
br label %13
13: ; preds = %11, %8
%14 = phi i8* [ null, %8 ], [ %12, %11 ]
ret i8* %14
}