#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 */

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ nondet();
int nondetpos();
int /*<<< orphan*/ validptr(int *);
int adpcm_decoder() {
  int len;
  int bufferstep;
  int n, nsamples;
  int *inp;
  int *outp;
  n = nondetpos();
  nsamples = 2 * n;
  inp = (int *)malloc(n * sizeof(int));
  outp = (int *)malloc(nsamples * sizeof(int));
  bufferstep = 0;
  len = nsamples;
  for (; 0 < len; len--) {
    if (bufferstep == 0) {
      validptr(inp);
      *inp = 0;
      inp++;
    } else {
      nondet();
    }
    bufferstep = 1 - bufferstep;
    validptr(outp);
    *outp = 0;
    outp++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<adpcm_decoder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <nondetpos@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jge    1206 <adpcm_decoder+0xc6>
cmpl   $0x0,-0x8(%rbp)
jne    11c7 <adpcm_decoder+0x87>
mov    -0x18(%rbp),%rdi
call   1060 <validptr@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    11ce <adpcm_decoder+0x8e>
mov    $0x0,%al
call   1030 <nondet@plt>
mov    $0x1,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <validptr@plt>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    118e <adpcm_decoder+0x4e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adpcm_decoder>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <nondetpos@plt>
mov    %eax,%r15d
lea    0x0(,%r15,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r14
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
test   %r15d,%r15d
jle    11d8 <adpcm_decoder+0x98>
mov    %rax,%rbx
lea    (%r15,%r15,1),%r12d
add    $0x1,%r12d
xor    %r15d,%r15d
jmp    11be <adpcm_decoder+0x7e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <nondet@plt>
mov    $0x1,%ebp
sub    %r15d,%ebp
mov    %rbx,%rdi
call   1060 <validptr@plt>
movl   $0x0,(%rbx)
add    $0x4,%rbx
add    $0xffffffff,%r12d
mov    %ebp,%r15d
cmp    $0x1,%r12d
jle    11d8 <adpcm_decoder+0x98>
test   %r15d,%r15d
jne    1190 <adpcm_decoder+0x50>
mov    %r14,%rdi
call   1060 <validptr@plt>
movl   $0x0,(%r14)
add    $0x4,%r14
jmp    1197 <adpcm_decoder+0x57>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @adpcm_decoder() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = call i32 (...) @nondetpos()
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = mul nsw i32 2, %8
store i32 %9, i32* %4
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %5
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i32*
store i32* %21, i32** %6
store i32 0, i32* %2
%22 = load i32, i32* %4
store i32 %22, i32* %1
br label %23
23: ; preds = %45, %0
%24 = load i32, i32* %1
%25 = icmp slt i32 0, %24
br i1 %25, label %26, label %48
26: ; preds = %23
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32*, i32** %5
%31 = call i32 @validptr(i32* %30)
%32 = load i32*, i32** %5
store i32 0, i32* %32
%33 = load i32*, i32** %5
%34 = getelementptr inbounds i32, i32* %33, i32 1
store i32* %34, i32** %5
br label %37
35: ; preds = %26
%36 = call i32 (...) @nondet()
br label %37
37: ; preds = %35, %29
%38 = load i32, i32* %2
%39 = sub nsw i32 1, %38
store i32 %39, i32* %2
%40 = load i32*, i32** %6
%41 = call i32 @validptr(i32* %40)
%42 = load i32*, i32** %6
store i32 0, i32* %42
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i32 1
store i32* %44, i32** %6
br label %45
45: ; preds = %37
%46 = load i32, i32* %1
%47 = add nsw i32 %46, -1
store i32 %47, i32* %1
br label %23
48: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
define i32 @adpcm_decoder() {
%1 = tail call i32 (...) @nondetpos()
%2 = shl i32 %1, 2
%3 = tail call i64 @malloc(i32 %2)
%4 = shl i32 %1, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %29
7: ; preds = %0
%8 = inttoptr i64 %5 to i32*
%9 = inttoptr i64 %3 to i32*
%10 = shl nuw nsw i32 %1, 1
br label %11
11: ; preds = %7, %22
%12 = phi i32* [ %26, %22 ], [ %8, %7 ]
%13 = phi i32* [ %23, %22 ], [ %9, %7 ]
%14 = phi i32 [ %27, %22 ], [ %10, %7 ]
%15 = phi i32 [ %24, %22 ], [ 0, %7 ]
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = tail call i32 @validptr(i32* %13)
store i32 0, i32* %13
%19 = getelementptr inbounds i32, i32* %13, i64 1
br label %22
20: ; preds = %11
%21 = tail call i32 (...) @nondet()
br label %22
22: ; preds = %20, %17
%23 = phi i32* [ %19, %17 ], [ %13, %20 ]
%24 = sub nsw i32 1, %15
%25 = tail call i32 @validptr(i32* %12)
store i32 0, i32* %12
%26 = getelementptr inbounds i32, i32* %12, i64 1
%27 = add nsw i32 %14, -1
%28 = icmp sgt i32 %14, 1
br i1 %28, label %11, label %29
29: ; preds = %22, %0
ret i32 0
}