#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_coder() {
  int len;
  int bufferstep;
  int n, nsamples;
  int *inp;
  int *outp;
  int *outp0;
  n = nondetpos();
  nsamples = 2 * n;
  inp = (int *)malloc(nsamples);
  outp = (int *)malloc(n);
  bufferstep = 1;
  len = nsamples;
  for (; 1 < len; len--) {
    validptr(inp);
    *inp = 0;
    inp++;
    if (bufferstep == 0) {
      validptr(outp);
      *outp = 0;
      outp++;
    } else {
      nondet();
    }
    bufferstep = 1 - bufferstep;
  }
  if (bufferstep == 0) {
    validptr(outp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<adpcm_coder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1050 <nondetpos@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x1,%eax
cmp    -0x4(%rbp),%eax
jge    11fb <adpcm_coder+0xbb>
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)
cmpl   $0x0,-0x8(%rbp)
jne    11db <adpcm_coder+0x9b>
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)
jmp    11e2 <adpcm_coder+0xa2>
mov    $0x0,%al
call   1030 <nondet@plt>
mov    $0x1,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1180 <adpcm_coder+0x40>
cmpl   $0x0,-0x8(%rbp)
jne    120e <adpcm_coder+0xce>
mov    -0x20(%rbp),%rdi
call   1060 <validptr@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adpcm_coder>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <nondetpos@plt>
mov    %eax,%r12d
lea    (%r12,%r12,1),%r14d
mov    %r14d,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %r12d,%edi
call   1040 <malloc@plt>
test   %r12d,%r12d
jle    11d9 <adpcm_coder+0x99>
mov    %rax,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <validptr@plt>
movl   $0x0,(%rbx)
xor    %eax,%eax
call   1030 <nondet@plt>
cmp    $0x3,%r14d
jl     11d1 <adpcm_coder+0x91>
lea    0x4(%rbx),%rdi
call   1060 <validptr@plt>
movl   $0x0,0x4(%rbx)
mov    %r15,%rdi
call   1060 <validptr@plt>
movl   $0x0,(%r15)
add    $0x4,%r15
lea    -0x2(%r14),%eax
add    $0x8,%rbx
cmp    $0x3,%r14d
mov    %eax,%r14d
jg     1180 <adpcm_coder+0x40>
jmp    11d9 <adpcm_coder+0x99>
mov    %r15,%rdi
call   1060 <validptr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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