#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 */
int /*<<< orphan*/ AES256_ECB(unsigned char *, unsigned char *,
                              unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
void AES256_CTR_DRBG_Update(unsigned char *provided_data, unsigned char *Key,
                            unsigned char *V) {
  unsigned char temp[48];
  for (int i = 0; i < 3; i++) {
    for (int j = 15; j >= 0; j--) {
      if (V[j] == 0xff)
        V[j] = 0x00;
      else {
        V[j]++;
        break;
      }
    }
    AES256_ECB(Key, V, temp + 16 * i);
  }
  if (provided_data != NULL)
    for (int i = 0; i < 48; i++)
      temp[i] ^= provided_data[i];
  memcpy(Key, temp, 32);
  memcpy(V, temp + 32, 16);
}


x86 assembly (clang, -O0):
<AES256_CTR_DRBG_Update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jge    11d1 <AES256_CTR_DRBG_Update+0xb1>
movl   $0xf,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jl     11a7 <AES256_CTR_DRBG_Update+0x87>
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xff,%eax
jne    117e <AES256_CTR_DRBG_Update+0x5e>
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1194 <AES256_CTR_DRBG_Update+0x74>
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
add    $0x1,%dl
mov    %dl,(%rax,%rcx,1)
jmp    11a7 <AES256_CTR_DRBG_Update+0x87>
jmp    1199 <AES256_CTR_DRBG_Update+0x79>
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
jmp    114c <AES256_CTR_DRBG_Update+0x2c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    -0x54(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rdx
call   1030 <AES256_ECB@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    113b <AES256_CTR_DRBG_Update+0x1b>
cmpq   $0x0,-0x8(%rbp)
je     121b <AES256_CTR_DRBG_Update+0xfb>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x30,-0x5c(%rbp)
jge    1216 <AES256_CTR_DRBG_Update+0xf6>
mov    -0x8(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
movslq -0x5c(%rbp),%rax
movzbl -0x50(%rbp,%rax,1),%ecx
xor    %edx,%ecx
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11e3 <AES256_CTR_DRBG_Update+0xc3>
jmp    121b <AES256_CTR_DRBG_Update+0xfb>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x20,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
add    $0x20,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES256_CTR_DRBG_Update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,0x68(%rsp)
lea    0xf(%rdx),%rbx
lea    0xe(%rdx),%r13
lea    0xd(%rdx),%rbp
lea    0xc(%rdx),%rax
mov    %rax,0x58(%rsp)
lea    0xb(%rdx),%rax
mov    %rax,0x50(%rsp)
lea    0xa(%rdx),%rax
mov    %rax,0x48(%rsp)
lea    0x9(%rdx),%rax
mov    %rax,0x40(%rsp)
lea    0x8(%rdx),%rax
mov    %rax,0x38(%rsp)
lea    0x7(%rdx),%rax
mov    %rax,0x30(%rsp)
lea    0x6(%rdx),%rax
mov    %rax,0x28(%rsp)
lea    0x5(%rdx),%rax
mov    %rax,0x20(%rsp)
lea    0x4(%rdx),%rax
mov    %rax,0x18(%rsp)
lea    0x3(%rdx),%rax
mov    %rax,0x10(%rsp)
lea    0x2(%rdx),%rax
mov    %rax,0x8(%rsp)
lea    0x1(%rdx),%rax
mov    %rax,0x60(%rsp)
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
mov    %rbx,%rcx
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
movb   $0x0,(%rbx)
movzbl 0x0(%r13),%eax
mov    %r13,%rcx
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
movb   $0x0,0x0(%r13)
movzbl 0x0(%rbp),%eax
mov    %rbp,%rcx
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
movb   $0x0,0x0(%rbp)
mov    0x58(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x58(%rsp),%rax
movb   $0x0,(%rax)
mov    0x50(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x50(%rsp),%rax
movb   $0x0,(%rax)
mov    0x48(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x48(%rsp),%rax
movb   $0x0,(%rax)
mov    0x40(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x40(%rsp),%rax
movb   $0x0,(%rax)
mov    0x38(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x38(%rsp),%rax
movb   $0x0,(%rax)
mov    0x30(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x30(%rsp),%rax
movb   $0x0,(%rax)
mov    0x28(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x28(%rsp),%rax
movb   $0x0,(%rax)
mov    0x20(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x20(%rsp),%rax
movb   $0x0,(%rax)
mov    0x18(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x18(%rsp),%rax
movb   $0x0,(%rax)
mov    0x10(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x10(%rsp),%rax
movb   $0x0,(%rax)
mov    0x8(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
mov    0x8(%rsp),%rax
movb   $0x0,(%rax)
mov    0x60(%rsp),%rcx
movzbl (%rcx),%eax
cmp    $0xff,%al
jne    1310 <AES256_CTR_DRBG_Update+0x1f0>
movb   $0x0,0x1(%r12)
movzbl (%r12),%eax
mov    %r12,%rcx
cmp    $0xff,%al
je     1337 <AES256_CTR_DRBG_Update+0x217>
nopl   0x0(%rax,%rax,1)
add    $0x1,%al
mov    %al,(%rcx)
lea    (%rsp,%r15,1),%rdx
add    $0x70,%rdx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <AES256_ECB@plt>
add    $0x10,%r15
cmp    $0x30,%r15
jne    11c0 <AES256_CTR_DRBG_Update+0xa0>
jmp    133e <AES256_CTR_DRBG_Update+0x21e>
movb   $0x0,(%r12)
jmp    1314 <AES256_CTR_DRBG_Update+0x1f4>
mov    0x68(%rsp),%rax
test   %rax,%rax
je     137d <AES256_CTR_DRBG_Update+0x25d>
movups (%rax),%xmm0
xorps  0x70(%rsp),%xmm0
movaps %xmm0,0x70(%rsp)
movups 0x10(%rax),%xmm0
xorps  0x80(%rsp),%xmm0
movaps %xmm0,0x80(%rsp)
movups 0x20(%rax),%xmm0
xorps  0x90(%rsp),%xmm0
movaps %xmm0,0x90(%rsp)
lea    0x70(%rsp),%rsi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <memcpy@plt>
lea    0x90(%rsp),%rsi
mov    %r12,%rdi
mov    $0x10,%edx
call   1040 <memcpy@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @AES256_CTR_DRBG_Update(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [48 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %8
br label %11
11: ; preds = %51, %3
%12 = load i32, i32* %8
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %54
14: ; preds = %11
store i32 15, i32* %9
br label %15
15: ; preds = %39, %14
%16 = load i32, i32* %9
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %42
18: ; preds = %15
%19 = load i8*, i8** %6
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %24, 255
br i1 %25, label %26, label %31
26: ; preds = %18
%27 = load i8*, i8** %6
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 0, i8* %30
br label %38
31: ; preds = %18
%32 = load i8*, i8** %6
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = add i8 %36, 1
store i8 %37, i8* %35
br label %42
38: ; preds = %26
br label %39
39: ; preds = %38
%40 = load i32, i32* %9
%41 = add nsw i32 %40, -1
store i32 %41, i32* %9
br label %15
42: ; preds = %31, %15
%43 = load i8*, i8** %5
%44 = load i8*, i8** %6
%45 = getelementptr inbounds [48 x i8], [48 x i8]* %7, i64 0, i64 0
%46 = load i32, i32* %8
%47 = mul nsw i32 16, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
%50 = call i32 @AES256_ECB(i8* %43, i8* %44, i8* %49)
br label %51
51: ; preds = %42
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %11
54: ; preds = %11
%55 = load i8*, i8** %4
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %79
57: ; preds = %54
store i32 0, i32* %10
br label %58
58: ; preds = %75, %57
%59 = load i32, i32* %10
%60 = icmp slt i32 %59, 48
br i1 %60, label %61, label %78
61: ; preds = %58
%62 = load i8*, i8** %4
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = load i32, i32* %10
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [48 x i8], [48 x i8]* %7, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = xor i32 %72, %67
%74 = trunc i32 %73 to i8
store i8 %74, i8* %70
br label %75
75: ; preds = %61
%76 = load i32, i32* %10
%77 = add nsw i32 %76, 1
store i32 %77, i32* %10
br label %58
78: ; preds = %58
br label %79
79: ; preds = %78, %54
%80 = load i8*, i8** %5
%81 = getelementptr inbounds [48 x i8], [48 x i8]* %7, i64 0, i64 0
%82 = call i32 @memcpy(i8* %80, i8* %81, i32 32)
%83 = load i8*, i8** %6
%84 = getelementptr inbounds [48 x i8], [48 x i8]* %7, i64 0, i64 0
%85 = getelementptr inbounds i8, i8* %84, i64 32
%86 = call i32 @memcpy(i8* %83, i8* %85, i32 16)
ret void
}

LLVM IR (-O2):
define void @AES256_CTR_DRBG_Update(i8* %0, i8* %1, i8* %2) {
%4 = alloca [48 x i8]
%5 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds i8, i8* %2, i64 15
%7 = getelementptr inbounds i8, i8* %2, i64 14
%8 = getelementptr inbounds i8, i8* %2, i64 13
%9 = getelementptr inbounds i8, i8* %2, i64 12
%10 = getelementptr inbounds i8, i8* %2, i64 11
%11 = getelementptr inbounds i8, i8* %2, i64 10
%12 = getelementptr inbounds i8, i8* %2, i64 9
%13 = getelementptr inbounds i8, i8* %2, i64 8
%14 = getelementptr inbounds i8, i8* %2, i64 7
%15 = getelementptr inbounds i8, i8* %2, i64 6
%16 = getelementptr inbounds i8, i8* %2, i64 5
%17 = getelementptr inbounds i8, i8* %2, i64 4
%18 = getelementptr inbounds i8, i8* %2, i64 3
%19 = getelementptr inbounds i8, i8* %2, i64 2
%20 = getelementptr inbounds i8, i8* %2, i64 1
br label %21
21: ; preds = %3, %100
%22 = phi i64 [ 0, %3 ], [ %104, %100 ]
%23 = load i8, i8* %6
%24 = icmp eq i8 %23, -1
br i1 %24, label %50, label %96
25: ; preds = %100
%26 = icmp eq i8* %0, null
br i1 %26, label %106, label %27
27: ; preds = %25
%28 = bitcast i8* %0 to <16 x i8>*
%29 = load <16 x i8>, <16 x i8>* %28
%30 = bitcast [48 x i8]* %4 to <16 x i8>*
%31 = load <16 x i8>, <16 x i8>* %30
%32 = xor <16 x i8> %31, %29
%33 = bitcast [48 x i8]* %4 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %33
%34 = getelementptr inbounds i8, i8* %0, i64 16
%35 = bitcast i8* %34 to <16 x i8>*
%36 = load <16 x i8>, <16 x i8>* %35
%37 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 16
%38 = bitcast i8* %37 to <16 x i8>*
%39 = load <16 x i8>, <16 x i8>* %38
%40 = xor <16 x i8> %39, %36
%41 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %40, <16 x i8>* %41
%42 = getelementptr inbounds i8, i8* %0, i64 32
%43 = bitcast i8* %42 to <16 x i8>*
%44 = load <16 x i8>, <16 x i8>* %43
%45 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 32
%46 = bitcast i8* %45 to <16 x i8>*
%47 = load <16 x i8>, <16 x i8>* %46
%48 = xor <16 x i8> %47, %44
%49 = bitcast i8* %45 to <16 x i8>*
store <16 x i8> %48, <16 x i8>* %49
br label %106
50: ; preds = %21
store i8 0, i8* %6
%51 = load i8, i8* %7
%52 = icmp eq i8 %51, -1
br i1 %52, label %53, label %96
53: ; preds = %50
store i8 0, i8* %7
%54 = load i8, i8* %8
%55 = icmp eq i8 %54, -1
br i1 %55, label %56, label %96
56: ; preds = %53
store i8 0, i8* %8
%57 = load i8, i8* %9
%58 = icmp eq i8 %57, -1
br i1 %58, label %59, label %96
59: ; preds = %56
store i8 0, i8* %9
%60 = load i8, i8* %10
%61 = icmp eq i8 %60, -1
br i1 %61, label %62, label %96
62: ; preds = %59
store i8 0, i8* %10
%63 = load i8, i8* %11
%64 = icmp eq i8 %63, -1
br i1 %64, label %65, label %96
65: ; preds = %62
store i8 0, i8* %11
%66 = load i8, i8* %12
%67 = icmp eq i8 %66, -1
br i1 %67, label %68, label %96
68: ; preds = %65
store i8 0, i8* %12
%69 = load i8, i8* %13
%70 = icmp eq i8 %69, -1
br i1 %70, label %71, label %96
71: ; preds = %68
store i8 0, i8* %13
%72 = load i8, i8* %14
%73 = icmp eq i8 %72, -1
br i1 %73, label %74, label %96
74: ; preds = %71
store i8 0, i8* %14
%75 = load i8, i8* %15
%76 = icmp eq i8 %75, -1
br i1 %76, label %77, label %96
77: ; preds = %74
store i8 0, i8* %15
%78 = load i8, i8* %16
%79 = icmp eq i8 %78, -1
br i1 %79, label %80, label %96
80: ; preds = %77
store i8 0, i8* %16
%81 = load i8, i8* %17
%82 = icmp eq i8 %81, -1
br i1 %82, label %83, label %96
83: ; preds = %80
store i8 0, i8* %17
%84 = load i8, i8* %18
%85 = icmp eq i8 %84, -1
br i1 %85, label %86, label %96
86: ; preds = %83
store i8 0, i8* %18
%87 = load i8, i8* %19
%88 = icmp eq i8 %87, -1
br i1 %88, label %89, label %96
89: ; preds = %86
store i8 0, i8* %19
%90 = load i8, i8* %20
%91 = icmp eq i8 %90, -1
br i1 %91, label %92, label %96
92: ; preds = %89
store i8 0, i8* %20
%93 = load i8, i8* %2
%94 = icmp eq i8 %93, -1
br i1 %94, label %95, label %96
95: ; preds = %92
store i8 0, i8* %2
br label %100
96: ; preds = %92, %89, %86, %83, %80, %77, %74, %71, %68, %65, %62, %59, %56, %53, %50, %21
%97 = phi i8* [ %6, %21 ], [ %7, %50 ], [ %8, %53 ], [ %9, %56 ], [ %10, %59 ], [ %11, %62 ], [ %12, %65 ], [ %13, %68 ], [ %14, %71 ], [ %15, %74 ], [ %16, %77 ], [ %17, %80 ], [ %18, %83 ], [ %19, %86 ], [ %20, %89 ], [ %2, %92 ]
%98 = phi i8 [ %23, %21 ], [ %51, %50 ], [ %54, %53 ], [ %57, %56 ], [ %60, %59 ], [ %63, %62 ], [ %66, %65 ], [ %69, %68 ], [ %72, %71 ], [ %75, %74 ], [ %78, %77 ], [ %81, %80 ], [ %84, %83 ], [ %87, %86 ], [ %90, %89 ], [ %93, %92 ]
%99 = add nuw i8 %98, 1
store i8 %99, i8* %97
br label %100
100: ; preds = %95, %96
%101 = shl nsw i64 %22, 4
%102 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 %101
%103 = call i32 @AES256_ECB(i8* %1, i8* %2, i8* %102)
%104 = add nuw nsw i64 %22, 1
%105 = icmp eq i64 %104, 3
br i1 %105, label %25, label %21
106: ; preds = %27, %25
%107 = call i32 @memcpy(i8* %1, i8* %5, i32 32)
%108 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 32
%109 = call i32 @memcpy(i8* %2, i8* %108, i32 16)
ret void
}