int yatzy_hand_score_kind4(int dice[], int count[]) {
  for (int i = 6; i > 0; i--) {
    if (count[i - 1] >= 4) {
      return (i * 4);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<yatzy_hand_score_kind4>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x6,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1155 <yatzy_hand_score_kind4+0x55>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x4,(%rax,%rcx,4)
jl     1142 <yatzy_hand_score_kind4+0x42>
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    115c <yatzy_hand_score_kind4+0x5c>
jmp    1147 <yatzy_hand_score_kind4+0x47>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1113 <yatzy_hand_score_kind4+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<yatzy_hand_score_kind4>:
mov    $0x18,%eax
cmpl   $0x3,0x14(%rsi)
jg     1142 <yatzy_hand_score_kind4+0x42>
mov    $0x14,%eax
cmpl   $0x3,0x10(%rsi)
jg     1142 <yatzy_hand_score_kind4+0x42>
mov    $0x10,%eax
cmpl   $0x3,0xc(%rsi)
jg     1142 <yatzy_hand_score_kind4+0x42>
mov    $0xc,%eax
cmpl   $0x3,0x8(%rsi)
jg     1142 <yatzy_hand_score_kind4+0x42>
mov    $0x8,%eax
cmpl   $0x3,0x4(%rsi)
jg     1142 <yatzy_hand_score_kind4+0x42>
xor    %eax,%eax
cmpl   $0x4,(%rsi)
setge  %al
shl    $0x2,%eax
ret

LLVM IR (-O0):
define i32 @yatzy_hand_score_kind4(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 6, i32* %6
br label %7
7: ; preds = %22, %2
%8 = load i32, i32* %6
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %11, i64 %14
%16 = load i32, i32* %15
%17 = icmp sge i32 %16, 4
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* %6
%20 = mul nsw i32 %19, 4
store i32 %20, i32* %3
br label %26
21: ; preds = %10
br label %22
22: ; preds = %21
%23 = load i32, i32* %6
%24 = add nsw i32 %23, -1
store i32 %24, i32* %6
br label %7
25: ; preds = %7
store i32 0, i32* %3
br label %26
26: ; preds = %25, %18
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @yatzy_hand_score_kind4(i32* nocapture readnone %0, i32* nocapture %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 5
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 3
br i1 %5, label %26, label %6
6: ; preds = %2
%7 = getelementptr inbounds i32, i32* %1, i64 4
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, 3
br i1 %9, label %26, label %10
10: ; preds = %6
%11 = getelementptr inbounds i32, i32* %1, i64 3
%12 = load i32, i32* %11
%13 = icmp sgt i32 %12, 3
br i1 %13, label %26, label %14
14: ; preds = %10
%15 = getelementptr inbounds i32, i32* %1, i64 2
%16 = load i32, i32* %15
%17 = icmp sgt i32 %16, 3
br i1 %17, label %26, label %18
18: ; preds = %14
%19 = getelementptr inbounds i32, i32* %1, i64 1
%20 = load i32, i32* %19
%21 = icmp sgt i32 %20, 3
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i32, i32* %1
%24 = icmp slt i32 %23, 4
%25 = select i1 %24, i32 0, i32 4
br label %26
26: ; preds = %22, %2, %6, %10, %14, %18
%27 = phi i32 [ 24, %2 ], [ 20, %6 ], [ 16, %10 ], [ 12, %14 ], [ 8, %18 ], [ %25, %22 ]
ret i32 %27
}