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

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ res_init();
int rrextract(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *,
              int /*<<< orphan*/ *, int);
int taint_data(int /*<<< orphan*/ *);
int main() {
  int msglen, ret;
  u_char *dp;
  u_char *name = (u_char *)malloc(100 * sizeof(u_char));
  u_char *msg = (u_char *)malloc(1000 * sizeof(u_char));
  msglen = taint_data(msg);
  if (0)
    printf("msglen = %d\n", msglen);
  dp = msg + sizeof(HEADER);
  if (0)
    printf("Calling rrextract!\n");
  res_init();
  ret = rrextract(msg, msglen, dp, name, 100);
  if (0)
    printf("rrextract returned %d\n", ret);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x190,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xfa0,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <taint_data@plt>
mov    %eax,-0x8(%rbp)
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <res_init@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x64,%r8d
call   1060 <rrextract@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x190,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0xfa0,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <taint_data@plt>
mov    %eax,%ebp
lea    0x10(%rbx),%r15
xor    %eax,%eax
call   1030 <res_init@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    $0x64,%r8d
call   1060 <rrextract@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i64 @malloc(i32 400)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %5
%9 = call i64 @malloc(i32 4000)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = call i32 @taint_data(i32* %11)
store i32 %12, i32* %2
%13 = load i32*, i32** %6
%14 = getelementptr inbounds i32, i32* %13, i64 4
store i32* %14, i32** %4
%15 = call i32 (...) @res_init()
%16 = load i32*, i32** %6
%17 = load i32, i32* %2
%18 = load i32*, i32** %4
%19 = load i32*, i32** %5
%20 = call i32 @rrextract(i32* %16, i32 %17, i32* %18, i32* %19, i32 100)
store i32 %20, i32* %3
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 400)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i64 @malloc(i32 4000)
%4 = inttoptr i64 %3 to i32*
%5 = tail call i32 @taint_data(i32* %4)
%6 = getelementptr inbounds i32, i32* %4, i64 4
%7 = tail call i32 (...) @res_init()
%8 = tail call i32 @rrextract(i32* %4, i32 %5, i32* %6, i32* %2, i32 100)
ret i32 0
}