#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);
  outp = (int *)malloc(nsamples);
  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)
mov    -0xc(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%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    11f8 <adpcm_decoder+0xb8>
cmpl   $0x0,-0x8(%rbp)
jne    11b9 <adpcm_decoder+0x79>
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    11c0 <adpcm_decoder+0x80>
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    1180 <adpcm_decoder+0x40>
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    (%r15,%r15,1),%r12d
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %r12d,%edi
call   1040 <malloc@plt>
test   %r15d,%r15d
jle    11c8 <adpcm_decoder+0x88>
mov    %rax,%rbx
add    $0x1,%r12d
xor    %r15d,%r15d
jmp    11ae <adpcm_decoder+0x6e>
nopl   0x0(%rax)
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    11c8 <adpcm_decoder+0x88>
test   %r15d,%r15d
jne    1180 <adpcm_decoder+0x40>
mov    %r14,%rdi
call   1060 <validptr@plt>
movl   $0x0,(%r14)
add    $0x4,%r14
jmp    1187 <adpcm_decoder+0x47>
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 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %5
%13 = load i32, i32* %4
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %6
store i32 0, i32* %2
%16 = load i32, i32* %4
store i32 %16, i32* %1
br label %17
17: ; preds = %39, %0
%18 = load i32, i32* %1
%19 = icmp slt i32 0, %18
br i1 %19, label %20, label %42
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32*, i32** %5
%25 = call i32 @validptr(i32* %24)
%26 = load i32*, i32** %5
store i32 0, i32* %26
%27 = load i32*, i32** %5
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %5
br label %31
29: ; preds = %20
%30 = call i32 (...) @nondet()
br label %31
31: ; preds = %29, %23
%32 = load i32, i32* %2
%33 = sub nsw i32 1, %32
store i32 %33, i32* %2
%34 = load i32*, i32** %6
%35 = call i32 @validptr(i32* %34)
%36 = load i32*, i32** %6
store i32 0, i32* %36
%37 = load i32*, i32** %6
%38 = getelementptr inbounds i32, i32* %37, i32 1
store i32* %38, i32** %6
br label %39
39: ; preds = %31
%40 = load i32, i32* %1
%41 = add nsw i32 %40, -1
store i32 %41, i32* %1
br label %17
42: ; preds = %17
ret i32 0
}

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