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


x86 assembly (clang, -O0):
<yatzy_hand_score_kind3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x6,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1153 <yatzy_hand_score_kind3+0x53>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x3,(%rax,%rcx,4)
jl     1140 <yatzy_hand_score_kind3+0x40>
imul   $0x3,-0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    115a <yatzy_hand_score_kind3+0x5a>
jmp    1145 <yatzy_hand_score_kind3+0x45>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1113 <yatzy_hand_score_kind3+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<yatzy_hand_score_kind3>:
mov    $0x12,%eax
cmpl   $0x2,0x14(%rsi)
jg     1142 <yatzy_hand_score_kind3+0x42>
mov    $0xf,%eax
cmpl   $0x2,0x10(%rsi)
jg     1142 <yatzy_hand_score_kind3+0x42>
mov    $0xc,%eax
cmpl   $0x2,0xc(%rsi)
jg     1142 <yatzy_hand_score_kind3+0x42>
mov    $0x9,%eax
cmpl   $0x2,0x8(%rsi)
jg     1142 <yatzy_hand_score_kind3+0x42>
mov    $0x6,%eax
cmpl   $0x2,0x4(%rsi)
jg     1142 <yatzy_hand_score_kind3+0x42>
xor    %eax,%eax
cmpl   $0x3,(%rsi)
setge  %al
lea    (%rax,%rax,2),%eax
ret

LLVM IR (-O0):
define i32 @yatzy_hand_score_kind3(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, 3
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* %6
%20 = mul nsw i32 %19, 3
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_kind3(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, 2
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, 2
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, 2
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, 2
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, 2
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i32, i32* %1
%24 = icmp slt i32 %23, 3
%25 = select i1 %24, i32 0, i32 3
br label %26
26: ; preds = %22, %2, %6, %10, %14, %18
%27 = phi i32 [ 18, %2 ], [ 15, %6 ], [ 12, %10 ], [ 9, %14 ], [ 6, %18 ], [ %25, %22 ]
ret i32 %27
}