#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 * sizeof(int));
  outp = (int *)malloc(n * sizeof(int));
  bufferstep = 1;
  len = nsamples;
  for (; 0 < 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)
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jge    1206 <adpcm_coder+0xc6>
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    11e6 <adpcm_coder+0xa6>
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    11ed <adpcm_coder+0xad>
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    118e <adpcm_coder+0x4e>
cmpl   $0x0,-0x8(%rbp)
jne    1219 <adpcm_coder+0xd9>
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   %rbx
xor    %eax,%eax
call   1050 <nondetpos@plt>
mov    %eax,%r14d
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0x0(,%r14,4),%edi
call   1040 <malloc@plt>
test   %r14d,%r14d
jle    11d9 <adpcm_coder+0x99>
mov    %rax,%r15
add    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <validptr@plt>
movl   $0x0,(%rbx)
xor    %eax,%eax
call   1030 <nondet@plt>
cmp    $0x2,%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    $0x2,%r14d
mov    %eax,%r14d
jg     1180 <adpcm_coder+0x40>
jmp    11d9 <adpcm_coder+0x99>
mov    %r15,%rdi
call   1060 <validptr@plt>
xor    %eax,%eax
pop    %rbx
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 = sext i32 %11 to i64
%13 = mul i64 %12, 4
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %5
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %6
store i32 1, i32* %2
%23 = load i32, i32* %4
store i32 %23, i32* %1
br label %24
24: ; preds = %46, %0
%25 = load i32, i32* %1
%26 = icmp slt i32 0, %25
br i1 %26, label %27, label %49
27: ; preds = %24
%28 = load i32*, i32** %5
%29 = call i32 @validptr(i32* %28)
%30 = load i32*, i32** %5
store i32 0, i32* %30
%31 = load i32*, i32** %5
%32 = getelementptr inbounds i32, i32* %31, i32 1
store i32* %32, i32** %5
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %27
%36 = load i32*, i32** %6
%37 = call i32 @validptr(i32* %36)
%38 = load i32*, i32** %6
store i32 0, i32* %38
%39 = load i32*, i32** %6
%40 = getelementptr inbounds i32, i32* %39, i32 1
store i32* %40, i32** %6
br label %43
41: ; preds = %27
%42 = call i32 (...) @nondet()
br label %43
43: ; preds = %41, %35
%44 = load i32, i32* %2
%45 = sub nsw i32 1, %44
store i32 %45, i32* %2
br label %46
46: ; preds = %43
%47 = load i32, i32* %1
%48 = add nsw i32 %47, -1
store i32 %48, i32* %1
br label %24
49: ; preds = %24
%50 = load i32, i32* %2
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32*, i32** %6
%54 = call i32 @validptr(i32* %53)
br label %55
55: ; preds = %52, %49
ret i32 0
}

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